2015 Multi-University Training Contest 1 Hdu5292 Pocket Cube
来源:互联网 发布:贪吃蛇 路径算法 编辑:程序博客网 时间:2024/05/14 13:59
Pocket Cube
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 110 Accepted Submission(s): 57
Problem Description
Pocket Cube is the 2×2×2 equivalent of a Rubik’s Cube(3×3×3). The cube consists of 8 pieces, all corners. (from wiki)
It was a Pocket Cube. Unfortunately, the Cube fell to the ground and broke. It took you some time to explore the construction of the Cube. Then you assembled the Pocket Cube. Unfortunately, you didn’t assembled it in the right way. So here is the question. You want to know whether it can return to the right position.
The right position means four blocks in each face has the same color. You can only rotate the Cube to return it to the right position.
A Cube is given in its layout.
The right position rotates in red face clockwisely.
You can get more details from input case.
w represents white , y represents yellow , o represents orange , r represents red , g represents green , b represents blue. In the right position, white and yellow , orange and red , green and blue are in the opposite face.
It was a Pocket Cube. Unfortunately, the Cube fell to the ground and broke. It took you some time to explore the construction of the Cube. Then you assembled the Pocket Cube. Unfortunately, you didn’t assembled it in the right way. So here is the question. You want to know whether it can return to the right position.
The right position means four blocks in each face has the same color. You can only rotate the Cube to return it to the right position.
A Cube is given in its layout.
The right position rotates in red face clockwisely.
You can get more details from input case.
w represents white , y represents yellow , o represents orange , r represents red , g represents green , b represents blue. In the right position, white and yellow , orange and red , green and blue are in the opposite face.
Input
The first line of input contains only one integer T(<=10000), the number of test cases.
Each case contains a Pocket Cube described above. After each case , there is a blacnk line. It guarantees that the corners of the Cube is right.
Each case contains a Pocket Cube described above. After each case , there is a blacnk line. It guarantees that the corners of the Cube is right.
Output
Each case contains only one line. Each line should start with “Case #i: ”,with i implying the case number, followed by “YES” or “NO”,”YES” means you can return it to the right position, otherwise “NO”.
Sample Input
2 g y g y o o w g r r o o w g r r b w b w y b y b r w g b b y o w o r y g y o g b r w o y b r w g
Sample Output
Case #1: YESCase #2: NO
#include<iostream>#include<cstdio>;using namespace std;// 不仅要求对面和为0,也要求本面和为0int v[]={1,1,1,1,1,1,0,0,-1,-1,1,1,0,0,-1,-1, -1,-1,-1,-1,0,0,0,0}; //AC//int v[]={1,-1,-1,1,-1,1,0,0,-1,1,1,-1,0,0,1,-1,// 1,-1,-1,1,0,0,0,0}; //WAint main(){ int T;cin>>T; for(int ca=1;ca<=T;ca++){ char str[2]; int ans=0; for(int i=0;i<24;i++){ cin>>str; if(str[0]=='w'||str[0]=='y') ans+=v[i]; } printf("Case #%d: ",ca); if(ans%3==0)puts("YES"); else puts("NO"); } return 0;}
0 0
- 2015 Multi-University Training Contest 1 Hdu5292 Pocket Cube
- 2015 Multi-University Training Contest 1 Hdu 5292 Pocket Cube
- 2015 Multi-University Training Contest 1
- 2015 Multi-University Training Contest 1记录
- 2015 Multi-University Training Contest 1
- 2015 Multi-University Training Contest 1
- 2015 Multi-University Training Contest 1
- 2015 Multi-University Training Contest 1
- 2015 Multi-University Training Contest 1
- 2015 Multi-University Training Contest 1
- 2015 Multi-University Training Contest 1
- hdu 5294 Tricks Device 2015 Multi-University Training Contest 1
- hdu 5289 Assignment 2015 Multi-University Training Contest 1
- 2015 Multi-University Training Contest 1 Hdu 5289 Assignment
- 2015 Multi-University Training Contest 1 Hdu 5297 Y sequence
- 2015 Multi-University Training Contest 1 Hdu5288 OO’s Sequence
- 2015 Multi-University Training Contest 1 题解 BY FZUw
- HDU 5289 Assignment (2015 Multi-University Training Contest 1)
- 虚拟机VMware3种网络模式(Bridged、NAT、Host-only)的工作原理
- android的编译和运行过程
- Java Mybatis 框架入门教程
- HDFS HA QJM
- 搭建EtherCAT通讯运动控制平台(三)beckoff公司产品订购
- 2015 Multi-University Training Contest 1 Hdu5292 Pocket Cube
- 自定义View之onMeasure()
- Linux I/O重定向
- 指针书和数组
- ubuntu下mysql-python模块的安装
- cxf+spring开发(二)--- Ip地址拦截器,限制客户端Ip地址,只允许数据库中已经配置的Ip地址
- 安卓+tomcat实现文件下载时文件名不能有中文和空格的解决方案
- 加载xib 描述的 tableViewCell
- Makefile中支持的函数大全