HDU 5292 Pocket Cube 结论题
Pocket Cube
题目连接:
http://acm.hdu.edu.cn/showproblem.php?pid=5292
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.
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.
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: YES
Case #2: NO
Hint
题意
给你一个二阶魔方,然后问你是否能够还原。
题解:
(黄色,白色),(绿色,蓝色),(红色,橙色)为对面色。每个角块为这三个集合中各取出一种颜色的组合。共8种。如图(1)所示,为每个方格附上权值。当该方格为黄色或白色时(其他对色组也可),加上方格上的权值。总和为3的倍数时可还原,否则不可以。必要性:从一个已经还原好的魔方出发,初始权值和为三的倍数。在旋转一个面的时候,权值和mod3不会发生变化。充分性:局部调整法。对于相邻的角块,可进行图(2)和图(3)不改变其他角块的变化。还原7个块后,mod3不变,第8块也已还原。
不要问我为什么,直接看题解……
代码
#include<bits/stdc++.h>
using namespace std;
string s;
int a[]={1,-1,-1,1,-1,1,0,0,-1,1,1,-1,0,0,1,-1,1,-1,-1,1,0,0};
int main()
{
int t;scanf("%d",&t);
for(int cas=1;cas<=t;cas++)
{
int ans = 0;
for(int i=0;i<24;i++)
{
cin>>s;
if(s[0]=='w'||s[0]=='y')
ans+=a[i];
}
printf("Case #%d: ",cas);
if(ans%3==0)printf("YES\n");
else printf("NO\n");
}
}
HDU 5292 Pocket Cube 结论题的更多相关文章
- HDU 4801 Pocket Cube
题目链接 去年现场,虎哥1Y的,现在刷刷题,找找状态... 一共6种转法,把3个面放到顶部,左旋和右旋,感觉写的还不错....都写成常数了. #include <stdio.h> #inc ...
- 2013区域赛长沙赛区现场赛 K - Pocket Cube
K - Pocket Cube Time Limit:10000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Su ...
- Pocket Cube
Pocket Cube http://acm.hdu.edu.cn/showproblem.php?pid=5983 Time Limit: 2000/1000 MS (Java/Others) ...
- 【】【】Pocket Cube
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total Submission(s) ...
- [codevs5578][咸鱼]tarjan/结论题
5578 咸鱼 时间限制: 1 s 空间限制: 128000 KB 题目描述 Description 在广袤的正方形土地上有n条水平的河流和m条垂直的河流,发达的咸鱼家族在m*n个河流交叉点都 ...
- BZOJ_1367_[Baltic2004]sequence_结论题+可并堆
BZOJ_1367_[Baltic2004]sequence_结论题+可并堆 Description Input Output 一个整数R Sample Input 7 9 4 8 20 14 15 ...
- [BZOJ3609][Heoi2014]人人尽说江南好 结论题
Description 小 Z 是一个不折不扣的 ZRP(Zealot Round-game Player,回合制游戏狂热玩家), 最近他 想起了小时候在江南玩过的一个游戏. 在过去,人们是要 ...
- 【uoj#282】长度测量鸡 结论题
题目描述 给出一个长度为 $\frac{n(n+1)}2$ 的直尺,要在 $0$ 和 $\frac{n(n+1)}2$ 之间选择 $n-1$ 个刻度,使得 $1\sim \frac{n(n+1)}2$ ...
- 【uoj#175】新年的网警 结论题+Hash
题目描述 给出一张 $n$ 个点 $m$ 条边的无向连通图,每条边的边权为1.对于每个点 $i$ ,问是否存在另一个点 $j$ ,使得对于任意一个不为 $i$ 或 $j$ 的点 $k$ ,$i$ 到 ...
随机推荐
- C++类型转换 -- 由其他类型转换到自定义类型
由其他类型转换到自定义类型 由其他类型(如int,double)向自定义类的转换是由构造函数来实现,只有当类的定义和实现中提供了合适的构造函数,转换才能通过. /******************* ...
- DataFrame衍生新特征操作
1.DataFrame中某一列的值衍生为新的特征 #将LBL1特征的值衍生为one-hot形式的新特征 piao=df_train_log.LBL1.value_counts().index #先构造 ...
- flask插件系列之flask_celery异步任务神器
现在继续学习在集成的框架中如何使用celery. 在Flask中使用celery 在Flask中集成celery需要做到两点: 创建celery的实例对象的名字必须是flask应用程序app的名字,否 ...
- maven工程的建立
/* 我曾经接触过一个Java web项目,在进行部署时,发现这个项目涉及了maven 没有接触过maven项目的我,发现了如果需要导入maven工程,需要先在eclipse里面对maven进行配置, ...
- 以应用带动SDN发展(CDN峰会 工信部杨崑)(转)
以应用带动SDN发展(CDN峰会 工信部杨崑) SDNAP推荐:这是在亚太全媒体SDN峰会由工信部研究院秘书长杨崑做的关于SDN的一个演讲,本人认为主讲者通过对整 个信息服务体系的精简归纳总结,剥 ...
- java关键字(详解)
目录 1. 基本类型 1) boolean 布尔型 2) byte 字节型 3) char 字符型 4) double 双精度 5) float 浮点 6) int 整型 7) long 长整型 8) ...
- 创建 dblink
目的:oracle中跨数据库查询 两台数据库服务器db_A(本地)和db_B(远程192.168.1.100),db_A下用户user_a 需要访问到db_B下user_b的数据解决:查询 ...
- linux sed命令查询结果前后批量追加内容(html文件批量修改css,js等文件路径)
1.需求:linux使用shell命令查询结果前后批量追加内容 例如:我需要在当前目录下所有的css文件路径前追加域名 我想的是用sed替换去实现,鲍哥的思路是用for循环 1.1方法1:鲍哥的for ...
- new Date()时间
var myDate = new Date(); myDate.toLocaleDateString():可以获取当前日期myDate.toLocaleTimeString(); 可以获取当前时间 扩 ...
- 易普优APS高级计划排程系统系列提纲:行业知识,业务建模,排程算法,计划可视化,平台框架,案例分享
专注于高级计划排程系统研发与实施10来年了,国内外各种APS软件基本都研究过,这里列个提纲主要从6个方面跟大家一起讨论分享,欢迎大家鼓掌或拍砖 易普优APS高级计划排程系统系列001:行业知识,APS ...