hdu Pocket Cube(结论题)

题意:给出一个二阶魔方的状态,求是否能还原;

参考:http://blog.csdn.net/squee_spoon/article/details/46990969(郑大cuber)

思路:一个二阶魔方的相邻角块交换情况如下图;

将终状态的每个方块赋值,旋转后权值不会变化;

考虑题干中黄白为对立面,将其权值赋0;

顺时针赋1,否则-1;

若黄白块的权值和被三整除,可还原;否则不可还原;

#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int t,n,m,ans;
char str[30];
int mark[]={1,-1,-1,1,-1,1,0,0,-1,1,1,-1,0,0,1,-1,1,-1,-1,1,0,0,0,0};
int main()
{
   int i,j,k,cas;
   scanf("%d",&t);
   for(cas=1;cas<=t;cas++)
   {
       ans=0;
       for(i=0;i<24;i++)
       {
           scanf("%s",str);
           if(str[0]==‘w‘||str[0]==‘y‘){
                ans+=mark[i];
           }
       }
       printf("Case #%d: ",cas);
       if(ans%3==0) printf("YES\n");
       else printf("NO\n");
   }
   return 0;
}
时间: 2024-12-26 16:35:08

hdu Pocket Cube(结论题)的相关文章

HDU 4801 Pocket Cube BFS

链接:http://vjudge.net/contest/view.action?cid=51289#problem/K 题意:给一个小魔方(每面只有四个小块),每个小块有自己的颜色(一共六种颜色,每种颜色四块),问经过最多N次操作(N<=7),每次操作是将魔方某一面转动90度,最多能使多少个面的四个小块颜色都相同. 思路:每次操作产生6种状态,(向前,向后,向左,向右,向上,向下,左半魔方向前和右半魔方向后的操作产生的状态本质是一样的)直接BFS搜索,可能产生的状态一共有6^7种,中间比较麻烦

HDU 4801 Pocket Cube(模拟题——转魔方)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4801 题面: Pocket Cube Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 882    Accepted Submission(s): 271 Problem Description Pocket Cube is a 3-D

HDU 5983 Pocket Cube

Pocket Cube Problem Description The Pocket Cube, also known as the Mini Cube or the Ice Cube, is the 2 × 2 × 2 equivalence of a Rubik's Cube.The cube consists of 8 pieces, all corners.Each piece is labeled by a three dimensional coordinate (h, k, l)

2013区域赛长沙赛区现场赛 K - Pocket Cube

K - Pocket Cube Time Limit:10000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 4801 Description Pocket Cube is a 3-D combination puzzle. It is a 2 × 2 × 2 cube, which means it is constructed by 8 mini-cubes.

【bzoj2079】[Poi2010]Guilds 构造结论题

题目描述 Zy皇帝面临一个严峻的问题,两个互相抵触的贸易团体,YYD工会和FSR工会,他们在同一时间请求在王国各个城市开办自己的办事处.这里有n个城市,其中有一些以双向马路相连,这两个工会要求每个城市应该做到: 1:有这个工会的办事处或 2:和另外一个符合1条件的城市有马路直接相连.(也就是每个城市必须是YYD的公会,但是又和FSR的公会的城市相连,或者是FSR的,和YYD的城市相连,或者和两个工会的城市相连)但是Zy怀疑不正当的竞争,他担心一个城市有两个工会的办事处,(就是说一个城市不能有两个

[dfs] zoj 3736 Pocket Cube

题目链接: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3736 Pocket Cube Time Limit: 2 Seconds      Memory Limit: 65536 KB Pocket Cube is a 3-D combination puzzle. It is a 2 × 2 × 2 cube, which means it is constructed by 8 mini-cubes. For

HDU 1221: Cube

HDU 1221: Cube ///@author Sycamore, ZJNU ///@accepted_on 2017-01-24 #include<iostream> using namespace std; int main() { int N; while (cin >> N) cout << N*N*N *(N*N*N - 1) / 2 - 3 * (N - 1)*N*N << endl; return 0; }

HDU - 3584 Cube (三维树状数组 + 区间改动 + 单点求值)

HDU - 3584 Cube Time Limit: 1000MS   Memory Limit: 65536KB   64bit IO Format: %I64d & %I64u Submit Status Description Given an N*N*N cube A, whose elements are either 0 or 1. A[i, j, k] means the number in the i-th row , j-th column and k-th layer. I

HDU 3584 Cube (三维 树状数组)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3584 Cube Problem Description Given an N*N*N cube A, whose elements are either 0 or 1. A[i, j, k] means the number in the i-th row , j-th column and k-th layer. Initially we have A[i, j, k] = 0 (1 <= i,