【模拟】Codeforces #444 C. Solution for Cube
来源:互联网 发布:c语言运行快捷键 编辑:程序博客网 时间:2024/04/30 17:17
实现起来有点难受,写了个长达三行的if语句,丑的要屎了
题意:给出一个二阶魔方的6面颜色,问能不能一部还原。
思路:只能转一下的话,说明有两个对立面已经还原好了,先判断是否有两个还原好的对立面。接着考虑向左向右转两种情况 ifififif好多if。
看到江老板冒泡切了这题!激动!
发现把这么多等号写成一个函数会轻松很多orz。
#include<bits/stdc++.h>using namespace std;int cu[25];bool same(int a[]){ for(int i=1;i<4;i++){ if(a[i]!=a[i-1]) return 0; } return 1;}bool ju(){ int pa = 0; int poi[10];int cnt = 0; if(same(cu+1)) pa+=1,poi[cnt++] = 1; if(same(cu+5)) pa+=2,poi[cnt++] = 2; if(same(cu+9)) pa+=6,poi[cnt++] = 3; if(same(cu+13)) pa+=3,poi[cnt++] = 4; if(same(cu+17)) pa+=4,poi[cnt++] = 5; if(same(cu+21)) pa+=5,poi[cnt++] = 6; if(cnt!=2 || pa!=7) return 0; if(poi[0]>poi[1]) swap(poi[0],poi[1]); if(poi[0] == 1 &&poi[1] == 3){ if(cu[5] == cu[6] &&cu[19]==cu[20]&&cu[5]==cu[19]&&cu[17]==cu[18]&&cu[18]==cu[23]&&cu[23]==cu[24]&&cu[21] == cu[22] &&cu[15]==cu[16]&&cu[22]==cu[15]&&cu[13] == cu[14] &&cu[7]==cu[8]&&cu[14]==cu[7]) return 1; if(cu[5] == cu[6] &&cu[15]==cu[16]&&cu[5]==cu[15]&&cu[13]==cu[14]&&cu[23]==cu[24]&&cu[13]==cu[23]&&cu[19] == cu[20] &&cu[21]==cu[22]&&cu[19]==cu[21]&&cu[17] == cu[18] &&cu[7]==cu[8]&&cu[17]==cu[7]) return 1; } if(poi[0] == 2 &&poi[1] == 6){ if(cu[11] == cu[12] &&cu[17]==cu[19]&&cu[12]==cu[17]&&cu[3]==cu[4]&&cu[18]==cu[20]&&cu[4]==cu[18]&&cu[1] == cu[2] &&cu[14]==cu[16]&&cu[2]==cu[14]&&cu[13] == cu[15] &&cu[9]==cu[10]&&cu[15]==cu[9]) return 1; if(cu[13] == cu[15] &&cu[3]==cu[4]&&cu[15]==cu[3]&&cu[1]==cu[2]&&cu[17]==cu[19]&&cu[2]==cu[17]&&cu[18] == cu[20] &&cu[9]==cu[10]&&cu[20]==cu[9]&&cu[11] == cu[12] &&cu[14]==cu[16]&&cu[12]==cu[14]) return 1; } if(poi[0] == 4 &&poi[1] == 5){ if(cu[5] == cu[7] &&cu[10]==cu[12]&&cu[7]==cu[10]&&cu[3]==cu[1]&&cu[6]==cu[8]&&cu[1]==cu[6]&&cu[2] == cu[4] &&cu[22]==cu[24]&&cu[2]==cu[22]&&cu[9] == cu[11] &&cu[21]==cu[23]&&cu[9]==cu[21]) return 1; if(cu[2] == cu[4] &&cu[5]==cu[7]&&cu[4]==cu[5]&&cu[6]==cu[8]&&cu[9]==cu[11]&&cu[10]==cu[12]&&cu[22] == cu[24] &&cu[12]==cu[22]&&cu[21]==cu[23]&&cu[1] == cu[3] &&cu[1]==cu[21]&&cu[8]==cu[9]) return 1; } return 0;}int main(){ for(int i=1;i<=24;i++){ cin>>cu[i]; } if(ju()) puts("YES"); else puts("NO");}
阅读全文
0 0
- 【模拟】Codeforces #444 C. Solution for Cube
- Codeforces Round #444 (Div. 2) C. Solution for Cube【模拟】
- codeforces C. Solution for Cube
- Codeforces 887C:Solution for Cube(模拟)
- Codeforces Round #444 (Div. 2) C. Solution for Cube
- codeforces 887 C. Solution for Cube(Codeforces Round #444 (Div. 2))
- Codeforces Round #444 (Div. 2)-C-Solution for Cube(魔方一步还原)
- Codeforces887C-Solution for Cube
- Codeforces 444C DZY Love Colors Solution
- Codeforces 309C Memory for Arrays 二进制模拟进位
- Security solution for TO C TO B
- CodeForces 382C【模拟】
- Codeforces 749C【模拟】
- CodeForces 118C 【模拟】
- Codeforces 863C 模拟
- codeforces 864C 模拟
- 模拟-Codeforces 777C
- June 11th 模拟赛C T1 Sandcas Solution
- 谈金丝雀部署
- 未成年程序猿少女之二
- 【小学生数据结构】树【并查集】史
- Nginx之日志拆分-yellowcong
- :after 、float
- 【模拟】Codeforces #444 C. Solution for Cube
- 拥抱大前端 盘点那些值得你了解的最佳开发实践
- [kuangbin带你飞]专题九 连通图 Critical Links UVA
- java8新特性回顾(三)
- K:DHCP工作过程
- Android studio 无法创建java类的解决办法
- 数据结构-栈的操作
- 搜索引擎和知识图谱那些事 (上).基础篇
- 07 rest-framework之视图函数基类和路由类