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. oracle优化原则(二)

    SQL优化原则 二.SQL语句编写注意问题 www.2cto.com 下面就某些SQL语句的where子句编写中需要注意的问题作详细介绍.在这些where子句中,即使某些列存在索引,但是由于编写了劣质 ...

  2. redhat enterprixe 5.0 DNS 服务配置与管理

    一.了解DNS相关概念 DNS是一个分布式数据库,在本地负责控制整个分布式数据库的部分段,每一段中的数据通过客户机/服务器模式在整个网络上存取.通过采用复制技术和缓存技术使得整个数据库稳定可靠的同时, ...

  3. Group by的使用方法

    sql中如果要分组查询,一般都会使用到group by语句,如何熟练使用group by语句呢,我分以下几点进行总结. Group by与聚合函数 Group by与Having 需要注意的地方 Gr ...

  4. 如果解决ubuntu tab键不能提示命令

    /bin/sh is symlinked to /bin/dashTo change it, do:sudo rm /bin/shsudo ln -s /bin/bash /bin/sh 原文:htt ...

  5. Android Fragment完全解析,关于碎片你所需知道的一切 (转)。

    我们都知道,Android上的界面展示都是通过Activity实现的,Activity实在是太常用了,我相信大家都已经非常熟悉了,这里就不再赘述. 但是Activity也有它的局限性,同样的界面在手机 ...

  6. Halcon 10.0:Hobject图像转CBitmap

    void HImage2CBitmap(Hobject pImage,CBitmap *wImage) { char lpcsType[MAX_STRING]; Hlong lPointer,widt ...

  7. POJ 2159 Ancient Cipher 难度:0

    题目链接:http://poj.org/problem?id=2159 #include <cstring> #include <cstdio> #include <cc ...

  8. NAND驱动

    NAND FLASH是一个存储芯片 那么: 这样的操作很合理"读地址A的数据,把数据B写到地址A" 问1. 原理图上NAND FLASH和S3C2440之间只有数据线,      ...

  9. Android Phonebook编写联系人UI加载及联系人保存流程(二)

    2014-01-06 17:18:29 1. Phonebook中新建/编辑联系人的UI不是用xml文件写的,它是随着帐号类型的改变来加载不同的UI,比如SIM联系人,只有Name.Phone Num ...

  10. 屏蔽Win10升级通知方法

    对于有系统洁癖的我来说,不喜欢还原和自动升级,我更乐意使用全新安装的方式来装系统! 据说微软也知道这种方式有时候的确很讨人嫌,因此就低调的在美国微软社区中给出了屏蔽这项通知的官方"大法&qu ...