POJ 2993 Emag eht htiw Em Pleh【模拟画棋盘】
来源:互联网 发布:ubuntu 中文改为英文 编辑:程序博客网 时间:2024/06/08 17:45
链接:
http://poj.org/problem?id=2993
http://acm.hust.edu.cn/vjudge/contest/view.action?cid=27454#problem/C
Emag eht htiw Em Pleh
Time Limit: 1000MS Memory Limit: 65536KTotal Submissions: 2280 Accepted: 1531
Description
This problem is a reverse case of the problem 2996. You are given the output of the problem H and your task is to find the corresponding input.
Input
according to output of problem 2996.
Output
according to input of problem 2996.
Sample Input
White: Ke1,Qd1,Ra1,Rh1,Bc1,Bf1,Nb1,a2,c2,d2,f2,g2,h2,a3,e4Black: Ke8,Qd8,Ra8,Rh8,Bc8,Ng8,Nc6,a7,b7,c7,d7,e7,f7,h7,h6
Sample Output
+---+---+---+---+---+---+---+---+|.r.|:::|.b.|:q:|.k.|:::|.n.|:r:|+---+---+---+---+---+---+---+---+|:p:|.p.|:p:|.p.|:p:|.p.|:::|.p.|+---+---+---+---+---+---+---+---+|...|:::|.n.|:::|...|:::|...|:p:|+---+---+---+---+---+---+---+---+|:::|...|:::|...|:::|...|:::|...|+---+---+---+---+---+---+---+---+|...|:::|...|:::|.P.|:::|...|:::|+---+---+---+---+---+---+---+---+|:P:|...|:::|...|:::|...|:::|...|+---+---+---+---+---+---+---+---+|.P.|:::|.P.|:P:|...|:P:|.P.|:P:|+---+---+---+---+---+---+---+---+|:R:|.N.|:B:|.Q.|:K:|.B.|:::|.R.|+---+---+---+---+---+---+---+---+
Source
CTU Open 2005
题意:
画棋盘
前面 ',' 前有三个字符的就画上第一个字符
如果只有二个字符的就画上字符P
如果是白色的位置的, 字符画大写
如果是黑色的位置的, 字符画小写
前面 ',' 前有三个字符的就画上第一个字符
如果只有二个字符的就画上字符P
如果是白色的位置的, 字符画大写
如果是黑色的位置的, 字符画小写
注意:
输入的字符小写字母代表方格所在的的"行"('a'为第一行, 从下往上数)
数字代表方格的列,
数字代表方格的列,
处理输入的字符前,要先初始化棋盘
坑:
1,棋子数可能是能放满棋盘的任意多个。【我开始就是坑在了这里,问了下GJ才知道】
2,可能先输入黑色,再输入白色
3,P 不一定放在最后, 可能放在前面或中间
2,可能先输入黑色,再输入白色
3,P 不一定放在最后, 可能放在前面或中间
算法:
简单模拟
思路:
没什么思路,细心就好了=_=
/*****************************************************Accepted168 KB0 msC++2849 B题意:画棋盘 前面 ',' 前有三个字符的就画上第一个字符 如果只有二个字符的就画上字符P 如果是白色的位置的, 字符画大写 如果是黑色的位置的, 字符画小写注意:输入的字符小写字母代表方格所在的的"行"('a'为第一行, 从下往上数) 数字代表方格的列, 处理输入的字符前,要先初始化棋盘坑:1,棋子数可能是能放满棋盘的任意多个。【我开始就是坑在了这里,问了下GJ才知道】 2,可能先输入黑色,再输入白色 3,P 不一定放在最后, 可能放在前面或中间算法:简单模拟思路:没什么思路,细心就好了=_=******************************************************/#include<stdio.h>#include<string.h>#include<algorithm>#include<iostream>using namespace std;char chess[20][40];char s1[100];char s2[100];char s[100];void solve(char s[], int flag) // 1= white, 0 = black{ int x,y; int len =strlen(s); //可能有任意多棋子,不能直接数 for(int i = 0; i < len;) //P (p) 可能输入在前面,不能分开计算 { if(s[i] >= 'A' && s[i] <= 'Z') { x = 2*(s[i+2]-'0') - 1; y = 4*(s[i+1]-'a'+1) - 2; if(flag) chess[x][y] = s[i]; else chess[x][y] = s[i]+32; i += 4; } else if(s[i] >= 'a' && s[i] <= 'z') { x = 2*(s[i+1]-'0') - 1; y = 4*(s[i]-'a'+1) - 2; if(flag) chess[x][y] = 'P'; else chess[x][y] = 'p'; i += 3; } }}int main(){ while(scanf("%s%s",s,s1) != EOF) { scanf("%s%s",s,s2); int flag1 = 1; //标记方格中两边的点 int flag2 = 1; // 标记方格中中间的点 for(int i = 0; i <= 16 ; i++) //初始化棋盘,如果看不懂,自己直接画一个赋值好了 { if(i%2 == 0)//+ - { for(int j = 0; j <= 32; j++) { if(j%4 == 0) chess[i][j] = '+'; else chess[i][j] = '-'; } } else if(i%2 == 1) // | :: .. { for(int j = 0; j <= 32; j += 4) { if(j%4 == 0) { chess[i][j] = '|'; //格子中两边的点 if(flag1 == 1) { chess[i][j+1] = ':'; chess[i][j+3] = ':'; } else if(flag1 == 0) { chess[i][j+1] = '.'; chess[i][j+3] = '.'; } flag1 = !flag1; //每行后面多填一个正好好标记下一行 //格子中中间的点 if(flag2 == 1) { chess[i][j+2] = ':'; } else if(flag2 == 0) { chess[i][j+2] = '.'; } flag2 = !flag2; //同上 } } } } if(s[0] == 'W') //s2为白色,大写 { solve(s1, 0); solve(s2, 1); } else //s2为黑色,小写 { solve(s1, 1); solve(s2, 0); } for(int i = 16; i >= 0; i--) { for(int j = 0; j <= 32; j++) printf("%c", chess[i][j]); printf("\n"); } } return 0;}
- POJ 2993 Emag eht htiw Em Pleh【模拟画棋盘】
- POJ 2993 Emag eht htiw Em Pleh 大模拟
- POJ 2993:Emag eht htiw Em Pleh:模拟题
- POJ 2993Emag eht htiw Em Pleh(模拟)
- POJ 2993 Emag eht htiw Em Pleh 模拟
- poj 2993 Emag eht htiw Em Pleh(模拟)
- POJ 2993-Emag eht htiw Em Pleh(模拟)
- POJ 2993 Emag eht htiw Em Pleh(模拟)
- POJ 2993 Emag eht htiw Em Pleh 模拟,题意
- POJ 2993 Emag eht htiw Em Pleh(模拟)
- POJ 2993 Emag eht htiw Em Pleh(模拟)
- Poj 2993 Emag eht htiw Em Pleh
- poj 2993 Emag eht htiw Em Pleh
- POJ 2993 Emag eht htiw Em Pleh
- poj 2993 Emag eht htiw Em Pleh
- Poj 2993 Emag eht htiw Em Pleh
- POJ 2993:Emag eht htiw Em Pleh
- Emag eht htiw Em Pleh(POJ--2993
- SSH登录linux妙用后台命令
- 什么是熵-------第四部分
- 使用ioctl添加网关产生Network is unreachable的原因
- IOS應用程序多語言本地化解决方案
- HDU 1728 逃离迷宫
- POJ 2993 Emag eht htiw Em Pleh【模拟画棋盘】
- TIPTOP ERP系统成本问题集
- restful client
- webbrowse
- python学习之路三(文件读写)
- Cstring 转 int 型问题(error C2664: “atoi”: 不能将参数 1 从“CString”转换为“const char *”))
- 一份用于生产环境的 preseed 文件
- Java与C通信要注意的几个问题
- WINDOWS下的各类HOOK