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

 #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. js js弹出框、对话框、提示框、弹窗总结

    js弹出框.对话框.提示框.弹窗总结 一.JS的三种最常见的对话框 //====================== JS最常用三种弹出对话框 ======================== //弹 ...

  2. 获取文件的MD5码(C#)

    using System; using System.IO; using System.Security.Cryptography; using System.Text; namespace Test ...

  3. Django框架和前端的的基本结合

    1 昨日回顾 a socket b 路由关系 c 模板字符串替换(模板语言) 主流web框架总结: django a用别人的 b自己写的 c自己写的 flask a用别人的 b自己写的 c用别人的(j ...

  4. MoveWindow和SetWindowPos

    SetWindowPos即使里面使用的是一样的矩形参数,有时候SetWindowPos还是会改变窗口的大小,真是坑爹!!! MoveWindow就不会改变 mark一下

  5. 基于H5+ API手机相册图片压缩上传

    // 母函数 function App(){} /** * 图片压缩,默认同比例压缩 * @param {Object} path * pc端传入的路径可以为相对路径,但是在移动端上必须传入的路径是照 ...

  6. Java中枚举类型Enum的一种使用方式

    枚举类定义如下: public enum Status { SCUUESS("1", "成功"), FAILED("2", "失败 ...

  7. How to install Eclipse in linux

    http://askubuntu.com/questions/26632/how-to-install-eclipse

  8. ObjectiveC中的赋值,对象拷贝,浅拷贝与深拷贝

    在开发过程中我们经常会遇到对象拷贝的问题,下面我们分别讨论赋值操作.对象拷贝.以及浅拷贝(Shallow copy)与深拷贝(Deep copy)的区别与各自的实现方式. 一.不同对象的赋值操作 Ob ...

  9. PHP框架深度解析

    PHP成为世界上最流行的脚本语言有许多原因:灵活性,易用性等等.但通常只用PHP或者其他语言编码就会显得单调.重复,这时候就需要一个PHP框架来代替程序员完成那些重复不变的部分.本文通过回答What, ...

  10. abp viewmodel的写法

    我的写法 public class QuotaCreateOrEditViewModel { public QuotaDto LoanQuota { get; set; } public bool I ...