快速切题 poj 2996 Help Me with the Game 棋盘 模拟 暴力 难度:0
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 3510 | Accepted: 2251 |
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
题目里的升兵为王果然没用
#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的更多相关文章
- 快速切题 poj 2993 Emag eht htiw Em Pleh 模拟 难度:0
Emag eht htiw Em Pleh Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 2806 Accepted: ...
- 快速切题 poj 1003 hangover 数学观察 难度:0
Hangover Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 103896 Accepted: 50542 Descr ...
- 快速切题 poj 1002 487-3279 按规则处理 模拟 难度:0
487-3279 Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 247781 Accepted: 44015 Descr ...
- 快速切题 poj 3026 Borg Maze 最小生成树+bfs prim算法 难度:0
Borg Maze Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 8905 Accepted: 2969 Descrip ...
- 快速切题 poj 2485 Highways prim算法+堆 不完全优化 难度:0
Highways Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 23033 Accepted: 10612 Descri ...
- POJ 1321 棋盘问题 dfs 难度:0
http://poj.org/problem?id=1321 注意是在'#'的地方放棋子 矩阵大小不过8*8,即使是8!的时间复杂度也足以承受,可以直接dfs求解 dfs时标注当前点的行和列已被访问, ...
- POJ 3522 Slim Span 最小生成树,暴力 难度:0
kruskal思想,排序后暴力枚举从任意边开始能够组成的最小生成树 #include <cstdio> #include <algorithm> using namespace ...
- poj 2739 Sum of Consecutive Prime Numbers 素数 读题 难度:0
Sum of Consecutive Prime Numbers Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 19697 ...
- poj 1258 Agri-Net 最小生成树 prim算法+heap不完全优化 难度:0
Agri-Net Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 41230 Accepted: 16810 Descri ...
随机推荐
- JAVA中传递的值还是引用的问题
public static void main(String[] args) { /*byte b[] = new byte[1024*1024*50]; System.out.println(b); ...
- python多线程为什么不能利用多核cpu
GIL 与 Python 线程的纠葛 GIL 是什么东西?它对我们的 python 程序会产生什么样的影响?我们先来看一个问题.运行下面这段 python 程序,CPU 占用率是多少? # 请勿在工作 ...
- Django的FBV和CB
Django的FBV和CBV FBV FBV(function base views) 就是在视图里使用函数处理请求. 在之前django的学习中,我们一直使用的是这种方式,所以不再赘述. CBV C ...
- FILE 文件的使用 (VC、BCB、Qt)
FILE * fp ;AnsiString filePath="";fp= fopen(filePath.c_str(),"wb");//第二个参数是文件打开方 ...
- activiti 数据表设计
activiti数据表分为5个部分: 通用数据表.流程存储表.身份数据表.运行时数据表.历史数据表 1.通用(general)数据表 以ACT_GE开头 资源表-act_ge_btyearray: 用 ...
- uva10817 dijkstra
大白书P330 #include <iostream> #include <cstdio> #include <algorithm> #include <st ...
- hdu5107 线段树
hdu 5107 这题说的是给了一个二维的 平面, 平面内有30000个点每个点都有自己的高度,然后又30000次的查询,每次查询给的是(X,Y,K), 要求出set(x,y){x,y|x<=X ...
- 【android】开发中遇到的一些问题
1:华为输入法,输入框为ACTION_DONE模式,ActionId是 UNSPECIFIED EditText对象.setImeOptions(EditorInfo.IME_ACTION_DONE) ...
- 图解Kerberos认证工作原理
本文是我在看了这篇英文说明之后的总结 https://technet.microsoft.com/zh-cn/library/cc961976.aspx 是总结,不是翻译,所以是我看后按自己的理解写的 ...
- JDBC 连接Oracle 数据库,JDBC 连接Mysql 数据库
首先是JDBC 连接Oracle 数据库 package com.util; import com.pojo.UserInfo; import java.sql.*; public class DB ...