LonLife 1046 chess play
来源:互联网 发布:php解析markdown 编辑:程序博客网 时间:2024/05/21 10:03
1046 - chess play
Time Limit:10s Memory Limit:64MByte
Submissions:717Solved:241
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(1≤n,m≤103,1≤q≤106)(1≤n,m≤103,1≤q≤106). Then follow qq lines are the operations.As for each operation, 1≤xi,yi≤n1≤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.....
SOLUTION
“玲珑杯”ACM比赛 Round #4
超时了好多次,就是交换行时,用字符串
#include<stdio.h>#include<string.h>#include<algorithm>using namespace std;int n,m;char map[1100][1100];char temp[1100];int main(){int t,a,x,y,x1,y1,q,i,j,k,b;scanf("%d",&t);while(t--){scanf("%d%d%d",&n,&m,&q);for(i=0;i<n;i++){for(j=0;j<m;j++){map[i][j]='.';}}while(q--){scanf("%d",&b);if(b==1){scanf("%d%d%d",&a,&x,&y);if(a==1){map[x-1][y-1]='w';}else if(a==2){map[x-1][y-1]='b'; }}else{scanf("%d%d",&x1,&y1); strcpy(temp,map[x1-1]); strcpy(map[x1-1],map[y1-1]); strcpy(map[y1-1],temp);}}for(i=0;i<n;i++){printf("%s\n",map[i]);}}return 0;}
0 0
- LonLife 1046 chess play
- 1046 - chess play
- 玲珑1046 chess play
- 【玲珑学院 1046 - chess play】
- 玲珑oj 1046- chess play【水】
- 玲珑杯-【 chess play】
- UVa 11614 - Etruscan Warriors Never Play Chess
- 玲珑比赛 A -- chess play【记忆模拟】
- “玲珑杯”ACM比赛 Round #4 A -- chess play
- chess
- Chess
- chess
- chess
- Chess
- Chess
- Chess
- chess
- Chess
- ---Filter ( 五 ) filter统一验证是否登录
- spring4之初步集成hibernate5
- Facebook的移动游戏野心:月底将在Messenger上推游戏服务
- 深入浅出的javascript的正则表达式学习教程
- Restful Web Api Get 和 Post 请求的参数设置
- LonLife 1046 chess play
- forward和redirect的区别
- Linux下统计当前文件夹下的文件个数、目录个数
- 信息更新小红点显示——自定义控件BadgeView的使用介绍
- 1112. Stucked Keyboard (20) (字符串处理)
- gcc与g++比较
- oneVsRest.data
- TabLayout使用
- material design lite学习(六)图标