Wednesday, April 23, 2014

Codeforces Coder-Strike 2014 - Finals (online edition, Div. 2), problem: (B) Start Up solution

Codeforces Coder-Strike 2014 - Finals (online edition, Div. 2), problem: (B) Start Up: http://codeforces.com/contest/421/problem/B

Codeforces Coder-Strike 2014 - Finals (online edition, Div. 2), problem: (B) Start Up solution: 

#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

int main()
{
   int flag=0;
   char s[100005];
   scanf("%s", s);
   for(int i=0; i<strlen(s); i++) {
       if(s[i]!='A' && s[i]!='H' && s[i]!='I' && s[i]!='M' && s[i]!='O' && s[i]!='T' && s[i]!='U' && s[i]!='V' && s[i]!='W' && s[i]!='X' && s[i]!='Y') {
           flag=1;
           break;
       }
   }
   if(flag==0) {
       for(int i=0; i<strlen(s)/2+1; i++) {
           if(s[i]!=s[strlen(s)-i-1]) {
               flag=1;
               break;
           }
       }
   }
   if(flag==1) printf("NO");
   else printf("YES");
   return 0;
}

note: look up the ascii table and see which letters mirror itself.

No comments:

Post a Comment