Advertisement
Saleh127

UVA 401

Nov 29th, 2020
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define test int t; cin>>t; for(int cs=1;cs<=t;cs++)
  5.  
  6. map<char, char> m;
  7. string s = "ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789";
  8. string r = "A 3 HIL JM O 2TUVWXY51SE Z 8 ";
  9.  
  10. bool mirror(string a)
  11. {
  12. ll l=a.size();
  13. for(ll i=0; i<l/2+l%2; i++)
  14. {
  15. if(a[l-i-1]!=m[a[i]])
  16. {
  17. return 0;
  18. }
  19. }
  20. return 1;
  21. }
  22.  
  23. bool palindrome(string a)
  24. {
  25. string c;
  26. c=a;
  27. reverse(c.begin(),c.end());
  28. if(c==a) return 1;
  29. else return 0;
  30. }
  31.  
  32.  
  33. int main()
  34. {
  35. ios_base::sync_with_stdio(0);
  36. cin.tie(0);
  37. cout.tie(0);
  38.  
  39. string a,b,c;
  40. ll i,j,k,l;
  41.  
  42. for(i=0; i<s.size(); i++)
  43. {
  44. m[s[i]]=r[i];
  45. }
  46. while(cin>>a)
  47. {
  48. bool mi=mirror(a);
  49. bool pa=palindrome(a);
  50.  
  51. if(!mi && !pa) cout<<a<<" -- is not a palindrome.\n"<<endl;
  52. else if(!mi && pa) cout<<a<<" -- is a regular palindrome.\n"<<endl;
  53. else if(mi && !pa) cout<<a<<" -- is a mirrored string.\n"<<endl;
  54. else cout<<a<<" -- is a mirrored palindrome.\n"<<endl;
  55.  
  56. }
  57.  
  58.  
  59. return 0;
  60. }
  61.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement