Help Me with the Game
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 3510   Accepted: 2251

Description

Your task is to read a picture of a chessboard position and print it in the chess notation.

Input

The input consists of an ASCII-art picture of a chessboard with chess pieces on positions described by the input. The pieces of the white player are shown in upper-case letters, while the black player's pieces are lower-case letters. The letters are one of "K" (King), "Q" (Queen), "R" (Rook), "B" (Bishop), "N" (Knight), or "P" (Pawn). The chessboard outline is made of plus ("+"), minus ("-"), and pipe ("|") characters. The black fields are filled with colons (":"), white fields with dots (".").

Output

The output consists of two lines. The first line consists of the string "White: ", followed by the description of positions of the pieces of the white player. The second line consists of the string "Black: ", followed by the description of positions of the pieces of the black player.

The description of the position of the pieces is a comma-separated list of terms describing the pieces of the appropriate player. The description of a piece consists of a single upper-case letter that denotes the type of the piece (except for pawns, for that this identifier is omitted). This letter is immediatelly followed by the position of the piece in the standard chess notation -- a lower-case letter between "a" and "h" that determines the column ("a" is the leftmost column in the input) and a single digit between 1 and 8 that determines the row (8 is the first row in the input).

The pieces in the description must appear in the following order: King("K"), Queens ("Q"), Rooks ("R"), Bishops ("B"), Knights ("N"), and pawns. Note that the numbers of pieces may differ from the initial position because of capturing the pieces and the promotions of pawns. In case two pieces of the same type appear in the input, the piece with the smaller row number must be described before the other one if the pieces are white, and the one with the larger row number must be described first if the pieces are black. If two pieces of the same type appear in the same row, the one with the smaller column letter must appear first.

Sample Input

+---+---+---+---+---+---+---+---+
|.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.|
+---+---+---+---+---+---+---+---+

Sample Output

White: Ke1,Qd1,Ra1,Rh1,Bc1,Bf1,Nb1,a2,c2,d2,f2,g2,h2,a3,e4
Black: Ke8,Qd8,Ra8,Rh8,Bc8,Ng8,Nc6,a7,b7,c7,d7,e7,f7,h7,h6
题目里的升兵为王果然没用
#include<cstdio>
#include <cstring>
#include <cctype>
using namespace std;
char maz[17][34];
char seq[2][6]={{'K','Q','R','B','N','P'},{'k','q','r','b','n','p'}};
bool first;
void subinsrt(int x,int y,char &ch){
ch=maz[2*x+1][4*y+2];
}
void scanner(char ch,bool fl){
char fnd;
if(fl)for(int i=0;i<8;i++){
for(int j=0;j<8;j++){
subinsrt(i,j,fnd);
if(ch==fnd){
if(first){
putchar(',');
}
else first=true;
if(ch!='P'&&ch!='p')putchar(toupper(ch));
printf("%c%d",j+'a',i+1);
}
}
}
else for(int i=7;i>=0;i--){
for(int j=0;j<8;j++){
subinsrt(i,j,fnd);
if(ch==fnd){
if(first){
putchar(',');
}
else first=true;
if(ch!='P'&&ch!='p')putchar(toupper(ch));
printf("%c%d",j+'a',i+1);
}
}
}
}
int main(){
for(int i=16;i>=0;i--)scanf("%s",maz[i]);
first=false;
printf("White: ");
for(int i=0;i<6;i++)scanner(seq[0][i],true);
puts("");
first=false;
printf("Black: ");
for(int i=0;i<6;i++)scanner(seq[1][i],false);
puts("");
return 0;
}

  

快速切题 poj 2996 Help Me with the Game 棋盘 模拟 暴力 难度:0的更多相关文章

  1. 快速切题 poj 2993 Emag eht htiw Em Pleh 模拟 难度:0

    Emag eht htiw Em Pleh Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 2806   Accepted:  ...

  2. 快速切题 poj 1003 hangover 数学观察 难度:0

    Hangover Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 103896   Accepted: 50542 Descr ...

  3. 快速切题 poj 1002 487-3279 按规则处理 模拟 难度:0

    487-3279 Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 247781   Accepted: 44015 Descr ...

  4. 快速切题 poj 3026 Borg Maze 最小生成树+bfs prim算法 难度:0

    Borg Maze Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 8905   Accepted: 2969 Descrip ...

  5. 快速切题 poj 2485 Highways prim算法+堆 不完全优化 难度:0

    Highways Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 23033   Accepted: 10612 Descri ...

  6. POJ 1321 棋盘问题 dfs 难度:0

    http://poj.org/problem?id=1321 注意是在'#'的地方放棋子 矩阵大小不过8*8,即使是8!的时间复杂度也足以承受,可以直接dfs求解 dfs时标注当前点的行和列已被访问, ...

  7. POJ 3522 Slim Span 最小生成树,暴力 难度:0

    kruskal思想,排序后暴力枚举从任意边开始能够组成的最小生成树 #include <cstdio> #include <algorithm> using namespace ...

  8. poj 2739 Sum of Consecutive Prime Numbers 素数 读题 难度:0

    Sum of Consecutive Prime Numbers Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 19697 ...

  9. poj 1258 Agri-Net 最小生成树 prim算法+heap不完全优化 难度:0

    Agri-Net Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 41230   Accepted: 16810 Descri ...

随机推荐

  1. jquery 获取对象

    jquery 获取对象 1.引用this作为对象时,必须以$(this)的形式变为对象目标,否则,无法识别,会报错“ has no method”

  2. Network of Schools---poj1236(强连通分量)

    题目链接 题意:学校有一些单向网络,现在需要传一些文件 求:1,求最少需要向几个学校分发文件才能让每个学校都收到, 2,需要添加几条网络才能从任意一个学校分发都可以传遍所有学校. 解题思路(参考大神的 ...

  3. (4.20)sql server性能指标、性能计数器

    (4.20)sql server性能指标.性能计数器 常规计数器 收集操作系统服务器的服务器性能信息,包括Processor.磁盘.网络.内存 Processor 处理器 1.1 % Processo ...

  4. 基于Sql Server 2008的分布式数据库的实践

    配置Sql Server 2008(Win7) 1.打开SQL server2012,使用windows身份登录 2.登录后,右键选择“属性”.左侧选择“安全性”,选中右侧的“SQL Server 和 ...

  5. shell 变量定义技巧总结

    可以多学习和模仿操作系统自带的/etc/init.d/functions函数库脚本的定义思路,多学习Linux系统脚本中的定义,有经验的读者最终应形成一套适合自己的规范和习惯. (1)变量名及变量内容 ...

  6. 需求:过滤下面这个网页里共723行 校对中里 行数为两位数的 行 并设置sz和rz在Windows和Linux之间发送和接收文件不用搭FTP

    需求:过滤下面这个网页里共723行 校对中里 行数为两位数的 行 并设置sz和rz在Windows和Linux之间发送和接收文件不用搭FTP 需求:过滤下面这个网页里共723行 校对中里 行数为两位数 ...

  7. 4.11 Routing -- Loading/Error Substates

    除了在上节中描述的技术,Ember路由器通过使用error和loading substates为自定义异步跳转提供强大而可重写的约定. 一.loading Substates 1. 在跳转过程中,Em ...

  8. SQL Server 一些使用小技巧

    1.查询的时候把某一个字段的值拼接成字符串 以下是演示数据. 第一种方式:使用自定义变量 ) SET @Names='' -- 需要先赋值为空字符串,不然结果会是 null SELECT @Names ...

  9. Horizon代码的层次结构

    Horizon中包含多个dashboard,每个dashboard又包含多个panel,每个panel有可以包含多个Tab.

  10. DB开发之postgresql

    1.环境变量配置: PGLIB=/usr/local/pgsql/lib PGDATA=$HOME/data PATH=$PATH:/usr/local/pgsql/bin MANPATH=$MANP ...