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
Time Limit:10s Memory Limit:64MByte
Submissions:777Solved:266
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.
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;
}