JosepRivaille

P71916: Anagrames

May 28th, 2015
1,108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.61 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4.  
  5. const int ABC = 26;
  6.  
  7. typedef vector<int> Row;
  8.  
  9. int main() {
  10.     int n;
  11.     cin >> n;
  12.     for (int i = 0; i < n; ++i) {
  13.         Row alfabet(ABC, 0);
  14.         char c;
  15.         while (cin >> c and c != '.') {
  16.             if (c >= 'A' and c <= 'Z') ++alfabet[c - 'A'];
  17.         }
  18.         while (cin >> c and c != '.') {
  19.             if (c >= 'A' and c <= 'Z') --alfabet[c - 'A'];
  20.         }
  21.         int j = 0;
  22.         bool trobat = false;
  23.         while (not trobat and j < ABC) {
  24.             if (alfabet[j] != 0) trobat = true;
  25.             else ++j;
  26.         }
  27.         if (trobat) cout << "NO" << endl;
  28.         else cout << "SI" << endl;
  29.     }
  30. }
  31.  
  32. //JosepRivaille
Advertisement
Add Comment
Please, Sign In to add comment