Bayan programming Contest 2014-2015 Qualification C-Extraterrestrial Rotations
来源:互联网 发布:没货源怎么开淘宝店 编辑:程序博客网 时间:2024/06/06 17:11
题目大意:给一个cube,按照“X,Y,Z”三种方式进行旋转,给出旋转方式以及旋转次数,然后旋转后的结果。
解题思路:开始以为要BFS去做,想了下只有三种方式,而次数再大只需要模4进行对应位输出即可。因此直接暴力就可以了,将三种旋转方式的规律写出来,然后模拟交换位置进行输出即可。详见code。
题目来源:http://contest.bayan.ir/en/contest/qualification_2014/problem/C/
code:
#include <iostream>#include <cstdio>#include <cstring>using namespace std;const int MOD = 4;const int MAXN = 11;int t,n,m;char str[6][MAXN];char ch[2];int main(){ //freopen("in.txt","r",stdin); //freopen("out.txt","w",stdout); scanf("%d",&t); getchar(); while(t--){ memset(str,0,sizeof(str)); for(int i=0;i<6;++i) scanf("%s",str[i]); scanf("%d",&n); for(int i=0;i<n;++i){ scanf("%s%d",ch,&m); int cnt=m%MOD; if(cnt==0) continue; if(ch[0]=='X'){ if(cnt==1){ char tmp[MAXN]; strcpy(tmp,str[0]); strcpy(str[0],str[2]); strcpy(str[2],str[5]); strcpy(str[5],str[1]); strcpy(str[1],tmp); } else if(cnt==2){ char tmp[MAXN]; strcpy(tmp,str[0]); strcpy(str[0],str[5]); strcpy(str[5],tmp); strcpy(tmp,str[1]); strcpy(str[1],str[2]); strcpy(str[2],tmp); } else if(cnt==3){ char tmp[MAXN]; strcpy(tmp,str[0]); strcpy(str[0],str[1]); strcpy(str[1],str[5]); strcpy(str[5],str[2]); strcpy(str[2],tmp); } } else if(ch[0]=='Y'){ if(cnt==1){ char tmp[MAXN]; strcpy(tmp,str[1]); strcpy(str[1],str[3]); strcpy(str[3],str[2]); strcpy(str[2],str[4]); strcpy(str[4],tmp); } if(cnt==2){ char tmp[MAXN]; strcpy(tmp,str[1]); strcpy(str[1],str[2]); strcpy(str[2],tmp); strcpy(tmp,str[3]); strcpy(str[3],str[4]); strcpy(str[4],tmp); } if(cnt==3){ char tmp[MAXN]; strcpy(tmp,str[1]); strcpy(str[1],str[4]); strcpy(str[4],str[2]); strcpy(str[2],str[3]); strcpy(str[3],tmp); } } else if(ch[0]=='Z'){ if(cnt==1){ char tmp[MAXN]; strcpy(tmp,str[0]); strcpy(str[0],str[3]); strcpy(str[3],str[5]); strcpy(str[5],str[4]); strcpy(str[4],tmp); } if(cnt==2){ char tmp[MAXN]; strcpy(tmp,str[0]); strcpy(str[0],str[5]); strcpy(str[5],tmp); strcpy(tmp,str[3]); strcpy(str[3],str[4]); strcpy(str[4],tmp); } if(cnt==3){ char tmp[MAXN]; strcpy(tmp,str[0]); strcpy(str[0],str[4]); strcpy(str[4],str[5]); strcpy(str[5],str[3]); strcpy(str[3],tmp); } } } for(int i=0;i<6;++i){ printf("%s",str[i]); if(i!=5) printf(" "); } printf("\n"); } return 0;}
0 0
- Bayan programming Contest 2014-2015 Qualification C-Extraterrestrial Rotations
- Bayan programming Contest 2014-2015 Qualification A-Bertaco's Police
- Bayan programming Contest 2014-2015 Qualification B-Weird Officer
- Bayan 2015 Contest Warm Up C题(DP+模拟)
- Bayan 2015 Contest Warm Up(C,D)
- Bayan 2015 Contest Warm Up
- Bayan 2015 Contest Warm Up
- Bayan 2015 Contest Warm Up (D题)
- CF 2013-2014 Samara SAU ACM ICPC Quarterfinal Qualification Contest C.Victor's Research
- Bayan 2015 Contest Warm Up D题(GCD)
- CF Bayan 2015 Contest Warm Up A.(模拟+预处理)
- CF Bayan 2015 Contest Warm Up B.(dfs+暴力)
- codeforce Bayan 2015 Contest Warm Up D CGCDSSQ
- Bayan 2015 Contest Warm Up D. CGCDSSQ (数论)
- map+pair Bayan 2015 Contest Warm Up D题
- Tutorials for The 10th SWJTU Collegiate Programming Contest - Qualification Round
- 2015 China Collegiate Programming Contest
- CF Bayan 2015 Contest Warm Up B. Kamal-ol-molk's Painting
- 【重读设计模式】模版方法模式
- 创建和销毁对象
- Hibernate 专题
- codeforces 474F Ant colony(线段树)
- Java的native方法
- Bayan programming Contest 2014-2015 Qualification C-Extraterrestrial Rotations
- 增加短信
- [置顶] View工作原理(四)view的layout过程
- Bayan programming Contest 2014-2015 Qualification B-Weird Officer
- Cocos2d-x_CCLabelProtocol(标签类)
- tcpdump详细用法
- HTML的电子邮件链接标签mailto用法详解
- 游戏框架其九:网和着色器( Mesh and Shader )
- 如何获取float变量在内存中的二进制数据?