UVA253----Cube painting

#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;

//FILE *fp=fopen("res.txt","w");

int main()
{
    char a[16];
    while(cin>>a){
        char s1[7];
        char s2[7];
        char stemp[7];
        for(int i=0;i<12;i++){
            if(i<6){
                s1[i]=a[i];
            }else{
                s2[i-6]=a[i];
            }
        }
        s1[6]='\0';
        s2[6]='\0';
        stemp[6]='\0';
        int test[6];
        int flag=0;
        for(int i=0;i<6;i++){
            int mid[4];
            test[0]=i;
            test[5]=5-i;
            if(i==0){
                mid[0]=1;
                mid[1]=2;
                mid[2]=3;
                mid[3]=4;
            }else if(i==1){
                mid[0]=5;
                mid[1]=2;
                mid[2]=3;
                mid[3]=0;
            }else if(i==2){
                mid[0]=5;
                mid[1]=4;
                mid[2]=1;
                mid[3]=0;
            }else if(i==3){
                mid[0]=5;
                mid[1]=1;
                mid[2]=4;
                mid[3]=0;
            }else if(i==4){
                mid[0]=5;
                mid[1]=3;
                mid[2]=2;
                mid[3]=0;
            }else{
                mid[0]=1;
                mid[1]=3;
                mid[2]=2;
                mid[3]=4;
            }
            for(int j=0;j<4;j++){
                int temp;
                temp=mid[1];
                mid[1]=mid[3];
                mid[3]=mid[2];
                mid[2]=mid[0];
                mid[0]=temp;
                for(int p=1;p<5;p++){
                    test[p]=mid[p-1];
                }
                /*for(int i=0;i<6;i++){
                    printf("%d",test[i]);
                }
                printf("\n");*/
                for(int f=0;f<6;f++){
                    stemp[f]=s1[test[f]];
                }
                if(strcmp(stemp,s2)==0){
                    flag=1;
                    break;
                }
            }
        }
        if(flag){
            printf("TRUE\n");
        }else{
            printf("FALSE\n");
        }
    }
    return 0;
}

穷举水题不解释

猜你喜欢

转载自blog.csdn.net/ShadowFox_/article/details/81163899