http://codeforces.com/gym/102219/problem/A
A. Mental Rotation
time limit per test
1.0 s
memory limit per test
256 MB
input
standard input
output
standard output
Mental rotation is a difficult thing to master. Mental rotation is the ability to imagine in your mind how an object would look like from a viewer's side if you were to rotate it in a particular direction. It is something very important for engineers to learn and master, especially if you are required to do engineering drawing. There are many stages to these mental rotation tasks. We will approach a simple rotation task in this problem.
If you are given the following square -
After rotating it to the right once, it will look like the following -
After rotating it to the left once, it will look like the following -
For this problem you will be given an initial square of size n and a list of rotations to perform.
Your task is to output the final representation of the square after performing all the rotation.
Input
The first line of input contains an integer NN (1 ≤ NN ≤ 1000). and a string containing a combination of ′L′′L′ and ′R′′R′. Where ′L′′L′ means left rotation and ′R′′R′ means right rotation. Length of the string will not exceed 100. Starting from the second line, the following NN line each will contain NN of the following characters (>>, <<, ∨∨, ∧∧ or ..). Empty space is indicated by a '..' (dot).
Output
The output should be NN lines, each containing NN characters representing the final representation of the square after all the rotation. For ∨∨ and ∧∧ use vv (small v) and Shift+6 respectively.
Examples
input
Copy
3 R >v> ... <^<
output
Copy
^.v >.< ^.v
input
Copy
3 L >v> ... <^<
output
Copy
^.v >.< ^.v
input
Copy
3 LL >v> ... <^<
output
Copy
>v> ... <^<
纯模拟
#include<iostream>
using namespace std;
char a[1005][1005], t[1005][1005];
int n;
string s;
void L_rotaing()
{
for(int i = 0; i < n; i++)
for(int j = 0; j < n; j++)
t[i][j] = a[j][n-1-i];
for(int i = 0; i < n; i++)
for(int j = 0; j < n; j++)
{
if(t[i][j] == '>') a[i][j] = '^';
else if(t[i][j] == '<') a[i][j] = 'v';
else if(t[i][j] == 'v') a[i][j] = '>';
else if(t[i][j] == '^') a[i][j] = '<';
else if(t[i][j] == '.') a[i][j] = '.';
}
}
void R_rotaing()
{
for(int i = 0; i < n; i++)
for(int j = 0; j < n; j++)
t[i][j] = a[n-j-1][i];
for(int i = 0; i < n; i++)
for(int j = 0; j < n; j++)
{
if(t[i][j] == '>') a[i][j] = 'v';
else if(t[i][j] == '<') a[i][j] = '^';
else if(t[i][j] == 'v') a[i][j] = '<';
else if(t[i][j] == '^') a[i][j] = '>';
else if(t[i][j] == '.') a[i][j] = '.';
}
}
int main()
{
cin >> n;
cin >> s;
for(int i = 0; i < n; i++)
for(int j = 0; j < n; j++)
cin >> a[i][j];
for(int i = 0; i < s.length(); i++)
if(s[i] == 'R')
R_rotaing();
else
L_rotaing();
for(int i = 0; i < n; i++,cout<<endl)
for(int j = 0; j < n; j++)
cout << a[i][j];
return 0;
}