PPBRQ - Rotating Cube
Main Problem Source
The Farfaraway planet is an extraterrestrial one. Recent astronomers' researches show that this planet is cube-shaped, and a word is written on each side of the cube. Also this weird planet has 3 types of rotations around 3 axises. Those are:
Rotation of type X: Right and left sides remain still, and the cube turns upward.
Rotation of type Y: Front and rear sides remain still, and the cube turns toward right.
Rotation of type Z: Top and bottom sides remain still, and the cube turns toward right.
Given a cube with some words written on its each side and a sequence of rotations, you should determine the word on each cube side.
Input
First line of input contains an integer T, denoting number of testcases.
In each testcase First line contains six words (consisting of english letters, and not longer than 10 characters), which are the initial words on Front, Top, Bottom, Left, Right, and Rear side of the cube. Second line contains a number N, number of rotation sequences. Next N line contain a character X, Y or Z indicating type of the rotation, followed by m indicating that rotation was performed m times.
Here, 1<=T<=1000, 1<=N<=100000, 1<=m<=10^9.
Output
For each testcase, output the words on Front, Top, Bottom, Left, Right, and Rear side after applying those rotations.
Sample test(s)
input
2
Front Up Down Left Right Back
2
Z 4
X 4
Front Up Down Left Right Back
3
Z 1
X 1
Y 1
output
Front Up Down Left Right Back
Down Back Front Right Left Up
input
1
a b c d e f
3
X 5
Y 5
Z 5
output
f d e b c a
hide comments
Dune:
2020-01-11 03:58:03
Very nice problem. Just fun. |
|
sonuverma:
2018-04-01 09:07:45
Very nice problem :-) |
|
Thotsaphon Thanatipanonda:
2015-11-05 00:33:13
For completed description goto http://contest.bayan.ir/en/contest/qualification_2014/problem/C/
|
|
sobriquet:
2015-01-23 13:15:52
No special test cases. Just double check your implementation. |
|
wisfaq:
2014-10-31 13:32:07
I think the time limit is too strict for many languages. Some languages have a start up time of about 0.5 sec.
|
|
Archangel:
2014-10-27 14:43:37
@Md. Najmuzzaman
|
Added by: | Najmuzzaman |
Date: | 2014-10-23 |
Time limit: | 0.200s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 GOSU |
Resource: | contest.bayan.ir/en/contest/qualification_2014 |