poj: 2159

简单题,看起来很凶

 1 #include <iostream>

 2 #include <stdio.h>

 3 #include <string>

 4 #include <stack>

 5 #include <map>

 6 #include <vector>

 7 #include <algorithm>

 8 using namespace std;

 9 

10 int main()

11 {

12     vector<int> S(26);

13     vector<int> T(26);

14     string first, second;

15     cin >> first >> second;

16     for (int i = 0; i < first.size(); ++i) {

17         S[first[i]-'A']++;

18         T[second[i]-'A']++;

19     }

20     bool same = true;

21     sort(S.begin(), S.end());

22     sort(T.begin(), T.end());

23     for (int i = 0; i < 26; ++i) {

24         if (S[i] != T[i]) {

25             same = false;

26             break;

27         }

28     }

29     if (same) cout << "YES" << endl;

30     else cout << "NO" << endl;

31 

32     return 0;

33 }

 

你可能感兴趣的:(poj)