暴力枚举——Help Me with the Game
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 3394 | Accepted: 2172 |
Description
Input
Output
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的更多相关文章
- CodeForces 742B Arpa’s obvious problem and Mehrdad’s terrible solution (暴力枚举)
题意:求定 n 个数,求有多少对数满足,ai^bi = x. 析:暴力枚举就行,n的复杂度. 代码如下: #pragma comment(linker, "/STACK:1024000000 ...
- 2014牡丹江网络赛ZOJPretty Poem(暴力枚举)
/* 将给定的一个字符串分解成ABABA 或者 ABABCAB的形式! 思路:暴力枚举A, B, C串! */ 1 #include<iostream> #include<cstri ...
- HNU 12886 Cracking the Safe(暴力枚举)
题目链接:http://acm.hnu.cn/online/?action=problem&type=show&id=12886&courseid=274 解题报告:输入4个数 ...
- 51nod 1116 K进制下的大数 (暴力枚举)
题目链接 题意:中文题. 题解:暴力枚举. #include <iostream> #include <cstring> using namespace std; ; ; ch ...
- Codeforces Round #349 (Div. 1) B. World Tour 最短路+暴力枚举
题目链接: http://www.codeforces.com/contest/666/problem/B 题意: 给你n个城市,m条单向边,求通过最短路径访问四个不同的点能获得的最大距离,答案输出一 ...
- bzoj 1028 暴力枚举判断
昨天梦到这道题了,所以一定要A掉(其实梦到了3道,有两道记不清了) 暴力枚举等的是哪张牌,将是哪张牌,然后贪心的判断就行了. 对于一个状态判断是否为胡牌,1-n扫一遍,然后对于每个牌,先mod 3, ...
- POJ-3187 Backward Digit Sums (暴力枚举)
http://poj.org/problem?id=3187 给定一个个数n和sum,让你求原始序列,如果有多个输出字典序最小的. 暴力枚举题,枚举生成的每一个全排列,符合即退出. dfs版: #in ...
- hihoCoder #1179 : 永恒游戏 (暴力枚举)
题意: 给出一个有n个点的无向图,每个点上有石头数个,现在的游戏规则是,设置某个点A的度数为d,如果A点的石子数大于等于d,则可以从A点给每个邻接点发一个石子.如果游戏可以玩10万次以上,输出INF, ...
- CCF 201312-4 有趣的数 (数位DP, 状压DP, 组合数学+暴力枚举, 推公式, 矩阵快速幂)
问题描述 我们把一个数称为有趣的,当且仅当: 1. 它的数字只包含0, 1, 2, 3,且这四个数字都出现过至少一次. 2. 所有的0都出现在所有的1之前,而所有的2都出现在所有的3之前. 3. 最高 ...
- hdu 1172 猜数字(暴力枚举)
题目 这是一道可以暴力枚举的水题. //以下两个都可以ac,其实差不多一样,呵呵 //1: //4 wei shu #include<stdio.h> struct tt { ],b[], ...
随机推荐
- Hyper-V和Virtual PC的不同
微软在2003年收购了推出了Virtual PC软件的Connectix公司,并在其后推出了Virtual Server服务器虚拟化软件 Hyper-V跟微软自家的Virtual PC.Virtual ...
- CentOS hadoop配置错误Incorrect configuration: namenode address dfs.namenode.servicerpc-address ...
# ./sbin/start-all.sh This script is Deprecated. Instead use start-dfs.sh and st ...
- [示例]NSPredicate基础-查询数组中负荷条件的子集
代码: #import <Foundation/Foundation.h> int main(int argc, const char * argv[]) { @autoreleasepo ...
- eclipse常用的字体
1.consolas 2.Segoe Script 3.Segoe Print 4.Courier New
- 利用开源框架Volley来下载文本和图片。
Android Volley是Android平台上很好用的第三方开源网络通信框架.使用简单,功能强大. 下载连接地址:http://download.csdn.net/detail/zhangphil ...
- (DFS)hdoj1241-Oil Deposit
#include<cstdio> ][]; ][]={{,},{,-},{,},{-,},{,},{,-},{-,},{-,-}},cnt; void dfs(int x,int y) { ...
- python 字典排序 关于sort()、reversed()、sorted()
一.Python的排序 1.reversed() 这个很好理解,reversed英文意思就是:adj. 颠倒的:相反的:(判决等)撤销的 print list(reversed(['dream','a ...
- 图解傅里叶变换(so easy)
话不多说先上两个GIF图. 第一个动画和第二个动画其实都是对时域的周期矩形形波(近似看成矩形波,并不是严格意义的矩形方波)进行傅里叶变换分析. 对于第一个图形来说,它侧重展示变换的本质之一:叠加性,每 ...
- c#读取文本文档实践1-File.ReadAllLines()
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.I ...
- [转][C/C++]函数名字修饰(Decorated Name)方式
1.C/C++函数修饰名: 对于我们的C/C++源程序而言,函数名只是函数的一小部分,函数还有调用方式(参数入栈方式).返回值类型.参数个数和各参数类型等信息,对于C++类成员函数,还有更多信息.这些 ...