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 ...
随机推荐
- hihocoder1636 Pangu and Stones
思路: 区间dp.dp[l][r][k]表示把区间[l, r]的石子合并成k堆所需要的最小代价. 实现: #include <iostream> #include <cstring& ...
- IE兼容rgba()透明度
一般浏览器的背景透明度可以直接设置 background:rgba(0,0,0,.5); -webkit-background:rgba(0,0,0,.5); -o-background:rgba(0 ...
- CString的GetBuffer和ReleaseBuffer
GetBuffer()主要作用是将字符串的缓冲区长度锁定,releaseBuffer则是解除锁定,使得CString对象在以后的代码中继续可以实现长度自适应增长的功能. CString ::GetBu ...
- SQL语句,mysql数据库
sql语句,把一张表里的数据,和特定数据(固定常量)新插入另一张表 ,,, from wm_jobpoint INSERT INTO wm_department(departmentcode,depa ...
- (十二)maven之nexus仓库的基本用法
nexus仓库的基本用法 ① 启动nexus. 上一章有提到:https://www.cnblogs.com/NYfor2018/p/9079068.html ② 访问http://localhost ...
- leetcode 127 单词接龙
给定两个单词(beginWord 和 endWord)和一个字典,找到从 beginWord 到 endWord 的最短转换序列的长度.转换需遵循如下规则: 每次转换只能改变一个字母. 转换过程中的中 ...
- vue2.0动画
相对于vue1.0来说,vue2.0的动画变化还是挺大的, 在1.0中,直接在元素中加 transition ,后面跟上名字. 而在vue2.0中,需要把设置动画的元素.路由放在<transit ...
- WPF知识点全攻略03- XAML
XAML 是一种声明性标记语言,XAML 是一种基于 XML 并对 XML 结构规则进行了扩展. XAML特点: 定义应用程序的界面元素 显示的声明WPF资源(样式.模板.动画等) 可扩展性(自定义U ...
- 网络流的$\mathfrak{Dinic}$算法
网络流想必大家都知道,在这不过多赘述.网络流中有一类问题是让你求最大流,关于这个问题,许多计算机学家给出了许多不同的算法,在这里--正如标题所说--我们只介绍其中的一种--\(\tt{Dinic}\) ...
- javaEE(13)_jdbc框架
一.使用模板方法设计模式简化开发 模板方法设计模式,执行一个程序有很多步骤,将每次都要执行的共有的提取出来放到一个抽象父类中,变化的部分通过让子类传递参数过来或将这部分抽象为抽象方法让子类通过继承的方 ...