模拟。下图是我做的小模型。

 #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的更多相关文章

  1. codevs 1766 装果子

    提交地址:http://codevs.cn/problem/1766/ 1766 装果子  时间限制: 1 s  空间限制: 256000 KB  题目等级 : 黄金 Gold     题目描述 De ...

  2. 51 nod 1766 树上的最远点对(线段树+lca)

    1766 树上的最远点对 基准时间限制:3 秒 空间限制:524288 KB 分值: 80 难度:5级算法题   n个点被n-1条边连接成了一颗树,给出a~b和c~d两个区间,表示点的标号请你求出两个 ...

  3. kylin cubing algorithm(算法)

    看到这一块的视频,结合光方博客的一些文档及自己的一点理解,记个笔记,以备不时之需. by layer cubing 1.on MR  这个算法的对cube的计算就像它的名字一样是按player进行的. ...

  4. Codeforces 311D Interval Cubing 数学 + 线段树 (看题解)

    Interval Cubing 这种数学题谁顶得住啊. 因为 (3 ^ 48) % (mod - 1)为 1 , 所以48个一个循环节, 用线段树直接维护. #include<bits/stdc ...

  5. 51nod 1766 树上的最远点对 | LCA ST表 线段树 树的直径

    51nod 1766 树上的最远点对 | LCA ST表 线段树 树的直径 题面 n个点被n-1条边连接成了一颗树,给出a~b和c~d两个区间,表示点的标号请你求出两个区间内各选一点之间的最大距离,即 ...

  6. 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 ...

  7. [51nod 1766]树上的最远点对 (树的直径+ST表求lca+线段树)

    [51nod 1766]树上的最远点对 (树的直径+ST表求lca+线段树) 题面 给出一棵N个点的树,Q次询问一点编号在区间[l1,r1]内,另一点编号在区间[l2,r2]内的所有点对距离最大值.\ ...

  8. 51Nod 1766 树上的最远点对

    Description 一棵树,询问两个端点编号分别在在 \([a,b]\) 和 \([c,d]\) 两个区间中的最长链. Sol 线段树+ST表. 树上最长链可以合并,只需要合并两个区间最长链的两个 ...

  9. swun 1766 我的悲剧不可能那么好数

    解题思路: 一向提交特别慎重的我,这题竟然PE了5发左右,放了几天,再回来写,直接1A, 相当的自豪,而且是最优解题者.这题千万要注意,化繁为简,文章只包括大小   写字母和数字,还有空行. #inc ...

随机推荐

  1. 对javascript变量提升跟函数提升的理解

    在写javascript代码的时候,经常会碰到一些奇怪的问题,例如: console.log(typeof hello); var hello = 123;//变量 function hello(){ ...

  2. GIMP 无法设置中文的问题解决

    首先按照网上说的安装了language-pack-gnome-zh-hant 参考链接:http://www.ubuntu-tw.org/modules/newbb/viewtopic.php?top ...

  3. react之——render prop

    在react “从上至下的数据流原则” 背景下,常规的消息传递机制就是通过prop属性,把父级数据传递给子级,这样一种数据流通模式决定了——数据的接收方子组件要被”硬植入“进数据的数据的给予方父组件, ...

  4. Azure powershell 获取 vmSize 可用列表的命令

    1.使用 Add-AzureAccount -Environment azurechinacloud 登录到订阅 2.选择默认的订阅 Select-AzureSubscription -Subscri ...

  5. 【R语言进行数据挖掘】回归分析

    1.线性回归 线性回归就是使用下面的预测函数预测未来观测量: 其中,x1,x2,...,xk都是预测变量(影响预测的因素),y是需要预测的目标变量(被预测变量). 线性回归模型的数据来源于澳大利亚的C ...

  6. MySQL 导出一句话

    听说是很老的东西了,学习的时候发现还是很好用的,故学习转载过来,留备学习. mysql 导出一句话 方法1:网上流行的方法 流程:(1)建表--->(2)插入数据--->(3)select ...

  7. Python学习日志9月17日 一周总结

    周一,9月11日 这天写的是过去一周的周总结,我从中找出当天的内容. 这天早晨给电脑折腾装机,早晨基本上没有学习,休息了一个早晨. 下午写的上周总结,完事做mooc爬虫课的作业,<Think P ...

  8. js 上传图片

    <div class="block-input" style="height: 90px"> <span><i class=&qu ...

  9. 带二级目录的Nginx配置------目前找到的最简单的方法

    由于项目不知一个,所以不得不为每一个项目建一个专有的文件夹,这就导致了在配置nginx的时候会出现二级目录 目前找到的最简单的方法     - step1:修改 vue.config.js   添加配 ...

  10. Codeforces Round #273 (Div. 2)-A. Initial Bet

    http://codeforces.com/contest/478/problem/A A. Initial Bet time limit per test 1 second memory limit ...