hdu 5292 Pocket Cube

来源:互联网 发布:脸太胖怎么办知乎 编辑:程序博客网 时间:2024/05/01 08:49

        给一个二阶魔方的状态,可能安装错了,问是否可以还原。

        作为一个Cuber,十分钟码出来怒拿此题FB。因为二阶魔方,可以做到交换任意两个块,所以块的位置是不用考虑的,只用考虑色向。因为黄白相对,考察黄白面的朝向,正确记为0,顺时针记为1,否则记为2,统统加起来能被3整除就是合法的。不要问我为什么,因为我是Cuber。

#include <iostream>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <string>#include <set>#include <algorithm>using namespace std;#define ll long longint main(){    int t;    cin>>t;    int cas=0;    while(t--){        cas++;        int ans=0;        for(int i=1;i<=24;i++){            char color[2];            scanf("%s",color);            if(color[0]=='w'||color[0]=='y'){                switch(i){                    case 5:                    case 7:                    case 9:                    case 12:                    case 14:                    case 16:                    case 21:                    case 24:                        ans++;                        break;                    case 6:                    case 8:                    case 10:                    case 11:                    case 13:                    case 15:                    case 22:                    case 23:                        ans+=2;                        break;                }            }        }        printf("Case #%d: ",cas);        if(ans%3==0){            printf("YES\n");        }else{            printf("NO\n");        }    }    return 0;}


0 0
原创粉丝点击