Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 3394   Accepted: 2172

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

Source

#include<cstdio>
#include<string.h>
using namespace std;
char str[][];
char s[];
int main()
{
int i,j;
int first=;
for(i=; i<; i++)
{
scanf("%s",s);
getchar();
scanf("%s",s);
for(j=; j<; j++)
str[i][j]=s[j*+];
}
printf("White: ");
for(i=; i>=; i--)
for(j=; j<; j++)
{
if(str[i][j]=='K')
{
if(first==)
{
printf("K%c%d",'a'+j,-i);
first=;
}
else printf(",K%c%d",'a'+j,-i);
}
}
for(i=; i>=; i--)
for(j=; j<; j++)
{
if(str[i][j]=='Q')
{
if(first==)
{
printf("Q%c%d",'a'+j,-i);
first=;
}
else printf(",Q%c%d",'a'+j,-i);
}
}
for(i=; i>=; i--)
for(j=; j<; j++)
{
if(str[i][j]=='R')
{
if(first==)
{
printf("R%c%d",'a'+j,-i);
first=;
}
else printf(",R%c%d",'a'+j,-i);
}
}
for(i=; i>=; i--)
for(j=; j<; j++)
{
if(str[i][j]=='B')
{
if(first==)
{
printf("B%c%d",'a'+j,-i);
first=;
}
else printf(",B%c%d",'a'+j,-i);
}
}
for(i=; i>=; i--)
for(j=; j<; j++)
{
if(str[i][j]=='N')
{
if(first==)
{
printf("N%c%d",'a'+j,-i);
first=;
}
else printf(",N%c%d",'a'+j,-i);
}
}
for(i=; i>=; i--)
for(j=; j<; j++)
{
if(str[i][j]=='P')
{
if(first==)
{
printf("%c%d",'a'+j,-i);
first=;
}
else printf(",%c%d",'a'+j,-i);
}
}
first=;
printf("\n");
printf("Black: ");
for(i=; i<=; i++)
for(j=; j<; j++)
{
if(str[i][j]=='k')
{
if(first==)
{
printf("K%c%d",'a'+j,-i);
first=;
}
else printf(",K%c%d",'a'+j,-i);
}
}
for(i=; i<=; i++)
for(j=; j<; j++)
{
if(str[i][j]=='q')
{
if(first==)
{
printf("Q%c%d",'a'+j,-i);
first=;
}
else printf(",Q%c%d",'a'+j,-i);
}
}
for(i=; i<=; i++)
for(j=; j<; j++)
{
if(str[i][j]=='r')
{
if(first==)
{
printf("R%c%d",'a'+j,-i);
first=;
}
else printf(",R%c%d",'a'+j,-i);
}
}
for(i=; i<=; i++)
for(j=; j<; j++)
{
if(str[i][j]=='b')
{
if(first==)
{
printf("B%c%d",'a'+j,-i);
first=;
}
else printf(",B%c%d",'a'+j,-i);
}
}
for(i=; i<=; i++)
for(j=; j<; j++)
{
if(str[i][j]=='n')
{
if(first==)
{
printf("N%c%d",'a'+j,-i);
first=;
}
else printf(",N%c%d",'a'+j,-i);
}
}
for(i=; i<=; i++)
for(j=; j<; j++)
{
if(str[i][j]=='p')
{
if(first==)
{
printf("%c%d",'a'+j,-i);
first=;
}
else printf(",%c%d",'a'+j,-i);
}
}
return ;
}

暴力枚举——Help Me with the Game的更多相关文章

  1. CodeForces 742B Arpa’s obvious problem and Mehrdad’s terrible solution (暴力枚举)

    题意:求定 n 个数,求有多少对数满足,ai^bi = x. 析:暴力枚举就行,n的复杂度. 代码如下: #pragma comment(linker, "/STACK:1024000000 ...

  2. 2014牡丹江网络赛ZOJPretty Poem(暴力枚举)

    /* 将给定的一个字符串分解成ABABA 或者 ABABCAB的形式! 思路:暴力枚举A, B, C串! */ 1 #include<iostream> #include<cstri ...

  3. HNU 12886 Cracking the Safe(暴力枚举)

    题目链接:http://acm.hnu.cn/online/?action=problem&type=show&id=12886&courseid=274 解题报告:输入4个数 ...

  4. 51nod 1116 K进制下的大数 (暴力枚举)

    题目链接 题意:中文题. 题解:暴力枚举. #include <iostream> #include <cstring> using namespace std; ; ; ch ...

  5. Codeforces Round #349 (Div. 1) B. World Tour 最短路+暴力枚举

    题目链接: http://www.codeforces.com/contest/666/problem/B 题意: 给你n个城市,m条单向边,求通过最短路径访问四个不同的点能获得的最大距离,答案输出一 ...

  6. bzoj 1028 暴力枚举判断

    昨天梦到这道题了,所以一定要A掉(其实梦到了3道,有两道记不清了) 暴力枚举等的是哪张牌,将是哪张牌,然后贪心的判断就行了. 对于一个状态判断是否为胡牌,1-n扫一遍,然后对于每个牌,先mod 3, ...

  7. POJ-3187 Backward Digit Sums (暴力枚举)

    http://poj.org/problem?id=3187 给定一个个数n和sum,让你求原始序列,如果有多个输出字典序最小的. 暴力枚举题,枚举生成的每一个全排列,符合即退出. dfs版: #in ...

  8. hihoCoder #1179 : 永恒游戏 (暴力枚举)

    题意: 给出一个有n个点的无向图,每个点上有石头数个,现在的游戏规则是,设置某个点A的度数为d,如果A点的石子数大于等于d,则可以从A点给每个邻接点发一个石子.如果游戏可以玩10万次以上,输出INF, ...

  9. CCF 201312-4 有趣的数 (数位DP, 状压DP, 组合数学+暴力枚举, 推公式, 矩阵快速幂)

    问题描述 我们把一个数称为有趣的,当且仅当: 1. 它的数字只包含0, 1, 2, 3,且这四个数字都出现过至少一次. 2. 所有的0都出现在所有的1之前,而所有的2都出现在所有的3之前. 3. 最高 ...

  10. hdu 1172 猜数字(暴力枚举)

    题目 这是一道可以暴力枚举的水题. //以下两个都可以ac,其实差不多一样,呵呵 //1: //4 wei shu #include<stdio.h> struct tt { ],b[], ...

随机推荐

  1. C#抽象类、抽象方法、抽象属性

    定义 在C#中使用关键字 abstract 来定义抽象类和抽象方法. 不能初始化的类被叫做抽象类,它们只提供部分实现,但是另一个类可以继承它并且能创建它们的实例."一个包含一个或多个纯虚函数 ...

  2. phonegap开发入门

    做了几次开发配置了,但时间一长就忘了,特记录一下. 一.环境变量配置::右击“我的电脑”-->"高级"-->"环境变量" 1.在系统变量里新建JAV ...

  3. Windows XP PRO SP3 - Full ROP calc shellcode

    /*     Shellcode: Windows XP PRO SP3 - Full ROP calc shellcode     Author: b33f (http://www.fuzzysec ...

  4. form v

    <form name="example_form" action="http://google.com" method="POST"& ...

  5. ubuntu连接Android调试

    从这周开始尝试Android开发,记下点滴. 安装JDK.下载ADT不说,连接手机调试的时候出错,一堆问号??????????.网上一查,属于典型错误.试下来,有几步比较关键,容易忽视: 1.我机器上 ...

  6. K2 BPM+Microsoft Dynamics CRM,妥妥的~

    啊~~~~七夕 ▼ 你比巴西少一xi 你比山西多四xi 对有情人来说今天就是情人节,对单身汪来说,今天就是个星期四. but,软件也是要秀恩爱的! ♥ 晒晒我家亲爱的CRM,它的全名叫Microsof ...

  7. (转载)重新对APK文件签名

    1.将证书(debug.keystore)复制到与需要重新签名的apk文件相同的目录下(如:复制到D:\Sign) 2.在cmd中切换到需要重新签名的apk文件的目录下 3.使用WinRAR打开要重新 ...

  8. C++指针(部分有误需修改)

    一.取地址运算符&(内存地址) C++编译的程序占用的内存分为以下几个部分: 1.栈区:由编译器自动分配释放 ,存放函数的参数值,局部变量的值等.其操作方式类似于数据结构中的栈.与其它分区不同 ...

  9. 关于Xcode调试的帖子,感觉不错,转来看看

    http://www.raywenderlich.com/10209/my-app-crashed-now-what-part-1 http://www.raywenderlich.com/10505 ...

  10. python 中的json解析库

    当一个json 数据很大的时候.load起来是很耗时的.python中常见的json解析库有cjson,simplesjson,json, 初步比较了一下, 对于loads来讲 simplejson ...