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. JSP中,当页面为404或者500时。设置跳转到错误提示页面

    最好的就是在WEB.XML文件中配置错误代码的跳转页面,首先建立个 出现500错误的页面,提示出错了,然后再WEB.XML文件中配置,配置如下 一. 通过错误码来配置error-page <er ...

  2. [工程备案]linux基本命令以及C和C++编程

    whereis 查看程序安装在了哪里 where 产看运行程序在哪里. libtool --mode=link  g++ test.cpp  -o test  libSegmentorForSim2T ...

  3. div在固定高的文字垂直居中

    <div style='display:table; height:100px;'> <div style='display:table-cell; vertical-align:  ...

  4. maven的安装与使用

    一.Maven是什么 Maven是一个采用纯Java编写的开 源项目管理工具.Maven采用了一种被称之为project object model (POM)概念来管理项目,所有的项目配置信息都被定义 ...

  5. 如何创建一个客户端回调:js获得服务端的内容?

    答案:表面上看去就是前端的js调用服务的C#方法,本质就是ajax,通过XMLHttpRequest对象和服务端进行交互.回调:就说回过头来调用,按理说js是一种脚本语言,怎么能用来调用服务端的呢?就 ...

  6. 一些qml资料

    qml开发ios应用 http://www.seanyxie.com/qt-qml%E7%A7%BB%E5%8A%A8%E5%BC%80%E5%8F%91%E4%B9%8B%E5%9C%A8ios%E ...

  7. Union all的用法实例sql

    ---Union all的用法实例sqlSELECT TOP (100) PERCENT ID, bid_user_id, UserName, amount, createtime, borrowTy ...

  8. 在虚拟机上安装Ubutu完成后卡在VM Tool的安装上

    今天在虚拟机上装Ubuntu之后,卡在了VM Tool的安装页,点击回车后可以进入命令行模式.并出现如下提示“Vmware Easy Install PLEASE WAIT! VMware Tools ...

  9. 二模 (12)day2

    第一题: 题目大意: 有N颗糖,两个人轮流取,每次只能取质数颗,不能取的输.求先取者若必胜,最少需要多少步胜利.(N<=10000) 解题过程: 1.看到N的范围比较小,先打个素数表,然后dp即 ...

  10. SharePoint 2013 Nintex Workflow 工作流帮助(七)

    博客地址 http://blog.csdn.net/foxdave 工作流动作 11. Check out item(Libraries and lists分组) 与上一个对应,用于签出条目.如果一个 ...