UVA 253 Cube painting 模拟题 枚举 我可是WA了好多次啊喂 明明是写过的题

来源:互联网 发布:c语言结构体赋值方法 编辑:程序博客网 时间:2024/04/29 02:58

 在之前校内训练的时候明明写过一次了,那一次还AC了

 这一次WA了估计快20发才A.......

 我就是不想手写暴力模拟好吗=_=||

 这一次给我的教训就是,在脑子里空想还不如在纸上推一推来的有效果..

 说起来CSDN为什么Tab键不给我留空格了?每一行都是顶着写太丑了

 枚举6次,每次枚举每一个面朝上,然后枚举4次,上下面确定的话,还是可以旋转3次的嘛,就是旋转这里......好吧,你手推一下会死呀!在脑子里空想,结果WA了快20发....

 搜题解的时候发现有人说只要27行,窝这个比你那个还要少哦~哼(笑)

 以上

#include <iostream>#include <algorithm>using namespace std;char ch[7],sh[7];int arr[7][7]{{1,2,3,4,5,6},{2,6,3,4,1,5},{3,2,6,1,5,4},{4,2,1,6,5,3},{5,1,3,4,6,2},{6,5,3,4,2,1}},tmp[4];inline bool cmp(char a1,char a2,char a3,char a4,char a5,char a6){return a1==sh[1]&&a2==sh[2]&&a3==sh[3]&&a4==sh[4]&&a5==sh[5]&&a6==sh[6];};bool flag=false;int main(){    ios_base::sync_with_stdio(false);    while(cin>>ch[1]>>ch[2]>>ch[3]>>ch[4]>>ch[5]>>ch[6]>>sh[1]>>sh[2]>>sh[3]>>sh[4]>>sh[5]>>sh[6]){        for(int i=0,j;i<6&&!flag;++i)        for(j=0,tmp[0]=arr[i][1],tmp[1]=arr[i][2],tmp[2]=arr[i][3],tmp[3]=arr[i][4];j<4&&!flag;++j,swap(tmp[2],tmp[1]),swap(tmp[1],tmp[0]),swap(tmp[3],tmp[2]))            flag|=cmp(ch[arr[i][0]],ch[tmp[0]],ch[tmp[1]],ch[tmp[2]],ch[tmp[3]],ch[arr[i][5]]);        cout<<(flag?"TRUE\n":"FALSE\n");        flag=false;    }    return 0;}


0 0
原创粉丝点击