253 - Cube painting

We have a machine for painting cubes. It is supplied with three different colors: blue, red and green. Each face of the cube gets one of these colors. The cube's faces are numbered as in Figure 1. Figure 1.

Since a cube has 6 faces, our machine can paint a face-numbered cube in different ways. When ignoring the face-numbers, the number of different paintings is much less, because a cube can be rotated. See example below. We denote a painted cube by a string of 6 characters, where each character is a br, or g. The character ( ) from the left gives the color of face i. For example, Figure 2 is a picture of rbgggr and Figure 3 corresponds to rggbgr. Notice that both cubes are painted in the same way: by rotating it around the vertical axis by 90 , the one changes into the other.  Input

The input of your program is a textfile that ends with the standard end-of-file marker. Each line is a string of 12 characters. The first 6 characters of this string are the representation of a painted cube, the remaining 6 characters give you the representation of another cube. Your program determines whether these two cubes are painted in the same way, that is, whether by any combination of rotations one can be turned into the other. (Reflections are not allowed.)

Output

The output is a file of boolean. For each line of input, output contains TRUE if the second half can be obtained from the first half by rotation as describes above, FALSE otherwise.

Sample Input

rbgggrrggbgrrrrbbbrrbbbrrbgrbgrrrrrg

Sample tput

TRUEFALSEFALSE

uva 253 思维问题：

{1,2,4,5,3,6},{1,3,2,4,5,6},{1,5,3,2,4,6},{1,4,5,3,2,6},

25为上下底也有4中情况

{2,6,4,1,3,5},{2,3,6,4,1,5},{2,1,3,6,4,5},{2,4,1,3,6,5},

43为上下底也有4种情况

{4,6,5,1,2,3},{4,2,6,5,1,3},{4,1,2,6,5,3},{4,5,1,2,6,3}};

52,34，分别和25,43相反

#include<stdio.h>#include<string.h>int a={{},{1,2,4,5,3,6},{1,3,2,4,5,6},{1,5,3,2,4,6},{1,4,5,3,2,6},{2,6,4,1,3,5},{2,3,6,4,1,5},{2,1,3,6,4,5},{2,4,1,3,6,5},{4,6,5,1,2,3},{4,2,6,5,1,3},{4,1,2,6,5,3},{4,5,1,2,6,3}}; //确定12种情况 然后结论相反char  ans;char  sample;char  input,output,converse;void inout()   {    int i,j;    for( i=0;i<6;i++){       input[i]=sample[i];       }             input[i]='\0';    for( j=0;j<6;j++,i++){       output[j]=sample[i];       }       output[j]='\0';  //       printf("%s %s\n",input,output);   }void changeform(){   int i,j,k;   for(i=1;i<=12;i++){      for(j=0;j<6;j++)          ans[i][j]=input[ a[i][j]-1 ];                      ans[i][j]='\0';   }       //   for(i=1;i<=12;i++)//      printf("%s\n",ans[i]);}void conver(){    char temp2,temp4,temp3;    temp2=output;    temp4=output;    temp3=output;    output=temp2;    output=temp3;    output=temp4;    int i,j;    for( i=5,j=0;j<6;j++,i--)       converse[j]=output[i];         converse[j]='\0';//    printf("%s\n",converse);    }int  check(){   int i,j,flag=0;        for(i=1;i<=12;i++)   {     if( strcmp(ans[i],output)==0 ){flag=1;break;}                       if( strcmp(ans[i],converse)==0 ){flag=1;break;}                   }     return flag;}int main(){    while (scanf("%s",sample)!=EOF){    inout();   //从输入数据中提取两个正方体颜色的排列    changeform();  //枚举出所有的12种情况      conver();  //改变数据的格式    if(check()==1)printf("TRUE\n") ;//验证数据结论    else printf("FALSE\n");    }}