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

 #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. nodejs 快要变成爬虫界的王者

    nodejs 快要变成爬虫界的王者 爬虫这东西是很多数据采集必须要的东西. 但是现在随着网页不断发展,已经出现了出单纯的网页,到 ajax 网页, 再到 spa , 再到 websocket 应用,一 ...

  2. 浅谈C++ 内存泄漏及其检测工具

    浅谈C++ 内存泄漏及其检测工具 http://wenku.baidu.com/link?url=1DGkOOvd_ITZyB8IHAwfhCOx2tfO6id8UfuyQkAMHZU6sasaAXz ...

  3. java代码(处理json串)

    package test; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; public class ...

  4. JBOSS连接池默认连接数是多少?在哪个配置文件有这个默认的连接数?

    如果你用的是是4.x的Jboss的话,请参考:docs/dtd/jboss-ds_1_0.dtd,相信你很容易就能找到控制最大/最小连接数的选项,应该是诸如:max-pool-size/min-poo ...

  5. POJ 1155 TELE (树形DP,树形背包)

    题意:给定一棵树,n个节点,其中有m个叶子表示的是用户,其他点表示中转器, 每条边都有权值,每个用户i愿意给的钱w[i],问如果在不亏钱的情况下能为多少用户转播足球比赛? 思路: 其实就是要选出部分叶 ...

  6. Window10 开启传统启动界面

    Windows 10沿袭了Windows 8的快速启动,导致在启动过程中无法通过按F8进入启动选项,这样当系统遇到问题无法进入时根本无法通过进入安全模式等方式进行处理(当然通过其他一些工具还是能够引导 ...

  7. ansible 调优

    1.设置ssh长链接ssh_args = -C -o ControlMaster=auto -o ControlPersist=5d 2.开启pipelining开启pipelining 需要被控制机 ...

  8. Linux系统分区 进程管理 软件包安装

    对于一块新的磁盘来说,系统能够使用需要有分区.格式化文件系统.挂载等主要操作,下面通过命令的方式对一块磁盘进行操作. 一. Linux系统分区 1.1 在虚拟机开机前选择虚拟机配置,添加一个新的SCS ...

  9. 解决VS2013无法安装ArcObjects10.2的问题

    之前在网上看到的10.1在vs2012安装不上的问题,解决办法是改注册表HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\1 ...

  10. Android Studio 中安装 apk 被拆分成多个 slice,如何禁止?

    Android Studio 3.0.1 中,Run 'app' 时,生成的 apk 被分割成多个 slice: $ adb install-multiple -r D:\...\app\build\ ...