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;
}