hlgoj 1766 Cubing
模拟。下图是我做的小模型。

#include <iostream>
#include <stdio.h>
#include <queue>
#include <stdlib.h>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <stack>
#include <map>
#include <vector>
#include <string>
using namespace std;
/*
剩下的就是正常的代码了
-------------------------------------------------
*/
char D[],T[],F[],B[],L[],R[];
void turn_face(char temp[]) //顺时针旋转一面
{
int i,j;
char t;
t=temp[];
temp[]=temp[]; temp[]=temp[]; temp[]=temp[]; temp[]=t;
t=temp[];
temp[]=temp[]; temp[]=temp[]; temp[]=temp[]; temp[]=t;
return;
}
void turn_D()
{
// cout<<"turn D\n";
char t[];
t[]=F[]; t[]=F[]; t[]=F[];
F[]=L[]; F[]=L[]; F[]=L[];
L[]=B[]; L[]=B[]; L[]=B[];
B[]=R[]; B[]=R[]; B[]=R[];
R[]=t[]; R[]=t[]; R[]=t[];
turn_face(D);
return ;
} void turn_T()
{
//cout<<"turn T\n";
char t[];
t[]=B[]; t[]=B[]; t[]=B[]; //R 1,4,7 -> B 7,8,9
B[]=L[]; B[]=L[]; B[]=L[]; //F 3,2,1 -> R 1,4,7
L[]=F[]; L[]=F[]; L[]=F[]; //L 9,6,3 -> F 3,2,1
F[]=R[]; F[]=R[]; F[]=R[]; //t 0,1,2 -> L 9,6,3
R[]=t[]; R[]=t[]; R[]=t[];
turn_face(T);
return ;
}
void turn_F()
{
// cout<<"turn F\n";
char t[];
t[]=T[]; t[]=T[]; t[]=T[];
T[]=L[]; T[]=L[]; T[]=L[];
L[]=D[]; L[]=D[]; L[]=D[];
D[]=R[]; D[]=R[]; D[]=R[];
R[]=t[]; R[]=t[]; R[]=t[];
turn_face(F);
return;
}
void turn_B()
{
//cout<<"turn B\n";
char t[];
t[]=D[]; t[]=D[]; t[]=D[];
D[]=L[]; D[]=L[]; D[]=L[];
L[]=T[]; L[]=T[]; L[]=T[];
T[]=R[]; T[]=R[]; T[]=R[];
R[]=t[]; R[]=t[]; R[]=t[];
turn_face(B);
return;
}
void turn_R()
{
//cout<<"turn L\n";
char t[];
t[]=F[]; t[]=F[]; t[]=F[];
F[]=D[]; F[]=D[]; F[]=D[];
D[]=B[]; D[]=B[]; D[]=B[];
B[]=T[]; B[]=T[]; B[]=T[];
T[]=t[]; T[]=t[]; T[]=t[];
turn_face(R);
return;
}
void turn_L()
{
// cout<<"turn R\n";
char t[];
t[]=F[]; t[]=F[]; t[]=F[];
F[]=T[]; F[]=T[]; F[]=T[];
T[]=B[]; T[]=B[]; T[]=B[];
B[]=D[]; B[]=D[]; B[]=D[];
D[]=t[]; D[]=t[]; D[]=t[];
turn_face(L);
return;
}
void init()
{
int i;
for(i=;i<;++i){
D[i]='y';
T[i]='w';
F[i]='r';
B[i]='o';
L[i]='g';
R[i]='b';
}
return;
}
int main()
{
string order;
int n,t;
int i;
while(cin>>t){
while(t--){
cin>>n;
init();
while(n--){
cin>>order;
if(order[]=='D'){
if(order[]=='+') turn_D();
else {
turn_D();turn_D();turn_D();
}
}
else if(order[]=='U'){
if(order[]=='+') turn_T();
else {
turn_T();turn_T();turn_T();
}
}
else if(order[]=='F'){
if(order[]=='+') turn_F();
else {
turn_F();turn_F();turn_F();
}
}
else if(order[]=='B'){
if(order[]=='+') turn_B();
else {
turn_B();turn_B();turn_B();
}
}
else if(order[]=='L'){
if(order[]=='+') turn_L();
else {
turn_L();
turn_L();
turn_L();
}
}
else if(order[]=='R'){
if(order[]=='+') turn_R();
else {
turn_R();turn_R();turn_R();
}
}
}
for(i=;i<;++i){
cout<<T[i];
if(i%==) cout<<endl;
}
}
}
return ;
}
hlgoj 1766 Cubing的更多相关文章
- codevs 1766 装果子
提交地址:http://codevs.cn/problem/1766/ 1766 装果子 时间限制: 1 s 空间限制: 256000 KB 题目等级 : 黄金 Gold 题目描述 De ...
- 51 nod 1766 树上的最远点对(线段树+lca)
1766 树上的最远点对 基准时间限制:3 秒 空间限制:524288 KB 分值: 80 难度:5级算法题 n个点被n-1条边连接成了一颗树,给出a~b和c~d两个区间,表示点的标号请你求出两个 ...
- kylin cubing algorithm(算法)
看到这一块的视频,结合光方博客的一些文档及自己的一点理解,记个笔记,以备不时之需. by layer cubing 1.on MR 这个算法的对cube的计算就像它的名字一样是按player进行的. ...
- Codeforces 311D Interval Cubing 数学 + 线段树 (看题解)
Interval Cubing 这种数学题谁顶得住啊. 因为 (3 ^ 48) % (mod - 1)为 1 , 所以48个一个循环节, 用线段树直接维护. #include<bits/stdc ...
- 51nod 1766 树上的最远点对 | LCA ST表 线段树 树的直径
51nod 1766 树上的最远点对 | LCA ST表 线段树 树的直径 题面 n个点被n-1条边连接成了一颗树,给出a~b和c~d两个区间,表示点的标号请你求出两个区间内各选一点之间的最大距离,即 ...
- identifier of an instance of com.xxx.model.system.xxxObject was altered from 1765 to 1766
Caused by: org.hibernate.HibernateException: identifier of an instance of com.xxx.model.system.xxxOb ...
- [51nod 1766]树上的最远点对 (树的直径+ST表求lca+线段树)
[51nod 1766]树上的最远点对 (树的直径+ST表求lca+线段树) 题面 给出一棵N个点的树,Q次询问一点编号在区间[l1,r1]内,另一点编号在区间[l2,r2]内的所有点对距离最大值.\ ...
- 51Nod 1766 树上的最远点对
Description 一棵树,询问两个端点编号分别在在 \([a,b]\) 和 \([c,d]\) 两个区间中的最长链. Sol 线段树+ST表. 树上最长链可以合并,只需要合并两个区间最长链的两个 ...
- swun 1766 我的悲剧不可能那么好数
解题思路: 一向提交特别慎重的我,这题竟然PE了5发左右,放了几天,再回来写,直接1A, 相当的自豪,而且是最优解题者.这题千万要注意,化繁为简,文章只包括大小 写字母和数字,还有空行. #inc ...
随机推荐
- Java GUI设置图标
ImageIcon是Icon接口的一个实现类. ImageIcon类的构造函数: ImageIcon() ImageIcon(String filename) //本地图片文件 ImageIcon ...
- phpmyadmin 出现Table 'root.pma_table_uiprefs' doesn't exist
原文链接:http://zhidao.baidu.com/link?url=ugBKDds94yxWhh_IZ6rZWZYSd2nO555EZ1WMClXRrqL0aKLc-HPDrZVSKZyDaD ...
- vs安装包
http://blog.csdn.net/cometnet/article/details/19551125
- 关于如何用jq定位到某个元素的索引
在点击事件触发时候,通常如果有同样的className的列表我们都需获取它的索引来知道到底点击的是那一个 $('.info_content').mousemove(function(){ var ro ...
- Android WiFi使用记录
最近在做Android的WiFi部分的开发,连接的工具类参照了这个文章的工具类. http://www.cnblogs.com/zhuqiang/p/3566686.html 开发中碰上的一些问题,在 ...
- 压力测试工具segie的使用
压力测试工具segie的使用 使用文档参考地址:https://www.joedog.org/siege-manual/ siege4地址:http://download.joedog.org/sie ...
- codevs 3096 流输入练习——寻找Sb.VI
时间限制: 1 s 空间限制: 16000 KB 题目等级 : 白银 Silver 题目描述 Description 已知某开放授权人员名叫Serb,由于经常修改各种数据,因此开发人员们都喊他SB ...
- off-by-one&doublefree. 看雪10月ctf2017 TSRC 第四题赛后学习
off-by-one 0x00 发现漏洞 1.off-by-one 在massage函数中,如图所示,可以修改的字节数比原内存大小多了一个字节 2.悬挂指针 可以看到,在free堆块的时候,没有清空指 ...
- UEditor中多图上传的bug
多图上传 预览:支持浏览器版本 IE8以上 在线管理:由于存在bug,显示不了 ueditor-1.1.1.jar解压后找到FileManager 1.修改com.baidu.ueditor.hun ...
- jdk concurrent 中 AbstractQueuedSynchronizer uml 图.
要理解 ReentrantLock 先理解AbstractQueuedSynchronizer 依赖关系. 2