iscsi

SRM 489 D1 300 BallsConverter

Aug 27th, 2011
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.80 KB | None | 0 0
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <sstream>
  4. #include <string>
  5. #include <vector>
  6. #include <queue>
  7. #include <set>
  8. #include <map>
  9. #include <cstdio>
  10. #include <cstdlib>
  11. #include <cctype>
  12. #include <cmath>
  13. using namespace std;
  14. typedef long long LL;
  15. #define FOR(k,a,b) for(int k(a); k < (b); ++k)
  16. #define REP(k,a) for(int k=0; k < (a); ++k)
  17.  
  18. class BallsConverter {
  19.     int calc(char c)
  20.     {
  21.         if(c>='A' && c<='Z')
  22.             return c-'A';
  23.         return c-'a'+26;
  24.     }
  25. public:
  26.    string theGood( vector <string> convert ) {
  27.        int n=convert.size();
  28.        REP(i,n)
  29.        REP(j,n)
  30.        {
  31.            if(convert[i][j]!=convert[j][i])
  32.                return "Bad";
  33.             REP(k,n)
  34.             {
  35.                 if(convert[i][calc(convert[j][k])]!=convert[j][calc(convert[i][k])])
  36.                     return "Bad";
  37.             }
  38.         }      
  39.        return "Good";
  40.    }
  41. };
Advertisement
Add Comment
Please, Sign In to add comment