UVA – 253 – Cube Painting

#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <string>
#include <set>
#include <map>

using namespace std;
#define lop(ii, ii0, iin) for(ii=ii0; ii<iin; ++ii)
#define rep(ii, NN) lop(ii, 0, NN)

#define hash(c1, c2) (256*min(c1,c2) + max(c2,c1))

char s[20];
int i, cont[100000];
int main() {


while (gets(s)) {
memset(cont, 0, sizeof cont);
rep(i, 3)
cont[hash(s[i], s[5-i])]++;
rep(i, 3)
if (cont[hash(s[6+i], s[11-i])])
cont[hash(s[6+i], s[11-i])]--;
else
break;

if (i == 3)
printf("TRUE\n");
else
printf("FALSE\n");
}
return 0;
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: