codeforces Mental Rotation (模拟 )

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;
	
}

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值