Emag eht htiw Em Pleh
Time Limit: 1000MS Memory Limit: 65536K
Total Submissions: 1646 Accepted: 1127
Description
This problem is a reverse case of the problem 2996. You are given the output of the problem H and your task is to find the corresponding input.
Input
according to output of problem 2996.
Output
according to input of problem 2996.
Sample Input
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
Sample Output
+---+---+---+---+---+---+---+---+
|.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.|
+---+---+---+---+---+---+---+---+
2996的逆过程,直接模拟,简单题。
代码:
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<string>
#include<ctype.h>
using namespace std;
char table[19][34];
char rd1[500],rd2[500];
void init_table()
{
memset(table,0,sizeof(table));
strcpy(table[0],"+---+---+---+---+---+---+---+---+\0");
strcpy(table[1],"|...|:::|...|:::|...|:::|...|:::|\0");
strcpy(table[2],"+---+---+---+---+---+---+---+---+\0");
strcpy(table[3],"|:::|...|:::|...|:::|...|:::|...|\0");
strcpy(table[4],"+---+---+---+---+---+---+---+---+\0");
strcpy(table[5],"|...|:::|...|:::|...|:::|...|:::|\0");
strcpy(table[6],"+---+---+---+---+---+---+---+---+\0");
strcpy(table[7],"|:::|...|:::|...|:::|...|:::|...|\0");
strcpy(table[8],"+---+---+---+---+---+---+---+---+\0");
strcpy(table[9],"|...|:::|...|:::|...|:::|...|:::|\0");
strcpy(table[10],"+---+---+---+---+---+---+---+---+\0");
strcpy(table[11],"|:::|...|:::|...|:::|...|:::|...|\0");
strcpy(table[12],"+---+---+---+---+---+---+---+---+\0");
strcpy(table[13],"|...|:::|...|:::|...|:::|...|:::|\0");
strcpy(table[14],"+---+---+---+---+---+---+---+---+\0");
strcpy(table[15],"|:::|...|:::|...|:::|...|:::|...|\0");
strcpy(table[16],"+---+---+---+---+---+---+---+---+\0");
}
void decode_w(char *str)
{
string temp = "";
int l = strlen(str);
for(int i=0;i<=l;i++)
{
if(str[i]==','||str[i]=='\0')
{
if(isupper(temp[0]))
{
int r = '8'-temp[2];
int c = temp[1]-'a';
r = 1+r*2;
c = 2+c*4;
table[r][c] = toupper(temp[0]);
}
else
{
int r = '8'-temp[1];
int c = temp[0]-'a';
r = 1+r*2;
c = 2+c*4;
table[r][c] = 'P';
}
temp = "";
}
else
{
temp+=str[i];
}
}
}
void decode_b(char *str)
{
string temp = "";
int l = strlen(str);
for(int i=0;i<=l;i++)
{
if(str[i]==','||str[i]=='\0')
{
if(isupper(temp[0]))
{
int r = '8'-temp[2];
int c = temp[1]-'a';
r = 1+r*2;
c = 2+c*4;
table[r][c] = tolower(temp[0]);
}
else
{
int r = '8'-temp[1];
int c = temp[0]-'a';
r = 1+r*2;
c = 2+c*4;
table[r][c] = 'p';
}
temp = "";
}
else
{
temp+=str[i];
}
}
}
void print_table()
{
for(int i=0;i<17;i++)
printf("%s\n",table[i]);
}
int main()
{
//freopen("datain.txt","r",stdin);
//freopen("dataout.txt","w",stdout);
while(scanf("White: %s%*c",rd1)!=EOF)
{
scanf("Black: %s%*c",rd2);
//printf("%s\n",rd1);
//printf("%s\n",rd2);
init_table();
decode_w(rd1);
decode_b(rd2);
print_table();
}
return 0;
}
分享到:
相关推荐
北大POJ2993-Emag eht htiw Em Pleh 解题报告+AC代码
2遍dp poj_3613解题报告 poj_3613解题报告
poj题目2775文件子目录源代码,递归经典题目,
poj典型题目解题思路详解 包含源代码和解题时应注意的问题及题目陷阱设计分析
poj 1699的代码和方法说明,个人原创
C_(POJ_1854)(分治).cpp
poj上第1990题目源码,用到了2个树状数组,这题数据结构是关键,想到了题目就很简单了
D_(POJ_1723)(思维)(sort).cpp
原理为:以数链思想,移动数组中的内容 使数组在没有扩充情况下,达成移动的效果 当然,有更简单的,大牛不要笑哦
D_(POJ_1723)(思维)(第k大数).cpp
O(nlogn)凸包问题 poj2187
POJ 3131 双向BFS解立体八数码问题
poj两道题的c++实现。已经测试过可以通过oj
这是北大在线测试的第1002题,方便记忆的电话号码的解题例程,题目中有一个列表,记录着许多方便记忆的电话号码。不同的方便记忆的电话号码可能对应相同的标准号码,这个程序的任务就是找到它们
问题:求平面上多个矩形的总面积。 算法:线段树(经典的线段树题目)
POJ题目及算法,包括动态规划、深搜广搜等算法。含相关注释。
看了测试用例后,大家估计已经明白题目的意思了吧!题目很简单,但是就是很烦。 开始直接是没思路,不知道怎么模拟,但是想了带该半个小时,就搞定了。就是把每个数存到数组里面。
poj 3310 的代码和方法说明,个人原创
http://poj.grids.cn/problem?id=2774 POJ 2774 木棒加工 木材厂有一些原木,现在想把这些木头切割成一些长度相同的小段木头,需要得到的小段的数目是给定了。当然,我们希望得到的小段越长越好,你的任务是计算能够...
POJ上面题目的解题报告。涵盖挺多的。可作参考。代码都正确。ACM新手入门必下~~ 加油...