玲珑比赛 A -- chess play【记忆模拟】

Start Time:2016-11-05 12:00:00 End Time:2016-11-05 17:00:00 Refresh Time:2016-11-06 21:38:47 Private

A -- chess play

Time Limit:10s Memory Limit:64MByte

Submissions:777Solved:266

DESCRIPTION

Bob has a n×mn×m chessboard, which has two kinds of chess pieces.one is black, and the other is white.
As for chessboard, you can do three operations:

  • 1 1 x y1 1 x y (means add a white chess piece to position (x, y))
  • 1 2 x y1 2 x y(means add a black chess piece to position (x, y))
  • 2 x1 x22 x1 x2(means swap the x1x1 row and x2x2 row)

(note: if you add one new chess to a position where there already is a chess, you need throw the old chess away firstly.)
In the initial time the chessboard is empty, and your mission is to show the final chessboard.
Please look at the example for more details.

INPUT
There are multiple test cases.The first line is a number T ( T 10T ≤10), which means the number of cases.For each case, the first line contains three integers n, m and q (1n,m103,1q106)(1≤n,m≤103,1≤q≤106). Then follow qq lines are the operations.As for each operation, 1xi,yin1≤xi,yi≤n
OUTPUT
Print n lines which containing m characters - the final chessboard.
SAMPLE INPUT
22 2 21 1 1 12 1 24 3 41 1 1 12 1 21 2 1 12 2 3
SAMPLE OUTPUT
..w.b.....w.....

AC代码:

#include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;
 
const int MAXN=1e3+11;
char G[MAXN][MAXN]; 
int a[MAXN];

int main()
{
	int T,N,M,Q; scanf("%d",&T);
	while(T--)
	{
		scanf("%d%d%d",&N,&M,&Q);
		for(int i=0;i<N;++i) {
			for(int j=0;j<M;++j) G[i][j]='.';
			G[i][M]='\0'; a[i]=i;
		}
		while(Q--) {
		     int x,y,o1,o2;
			 scanf("%d",&o1);
			 if(o1==1) {
                   scanf("%d%d%d",&o2,&x,&y);
				   G[a[x-1]][y-1]=o2==1?'w':'b';
             }
			 else {
			 	scanf("%d%d",&x,&y);
			 	swap(a[x-1],a[y-1]);
			 }
		}
		for(int i=0;i<N;++i) printf("%s\n",G[a[i]]);
    } 
	return 0;
 } 


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值