Emag eht htiw Em Pleh
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 3406 | Accepted: 2235 |
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.| +---+---+---+---+---+---+---+---+
Source
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
int main()
{
int i,j,t=0;
char str1[1000],st1[100];
char str2[1000],st2[100];
char MAP[20][40];
memset(MAP,0,sizeof(MAP));
scanf("%s %s",st1,str1);
scanf("%s %s",st2,str2);
int len1,len2,a,b;
len1=strlen(str1);
len2=strlen(str2);
for(i=0;i<len1;)
{
if(str1[i]=='K'||str1[i]=='Q'||str1[i]=='R'||str1[i]=='B'||str1[i]=='N')
{
b=(str1[i+1]-'a')*4+2;
a=('8'-str1[i+2])*2+1;
MAP[a][b]=str1[i];
//printf("%c %d %d\n",MAP[a][b],a,b);
i=i+4;
}
else
{
b=(str1[i]-'a')*4+2;
a=('8'-str1[i+1])*2+1;
MAP[a][b]='P';
//printf("%c %d %d\n",MAP[a][b],a,b);
i=i+3;
}
}
//printf("\n***\n");
for(i=0;i<len2;)
{
if(str2[i]=='K'||str2[i]=='Q'||str2[i]=='R'||str2[i]=='B'||str2[i]=='N')
{
b=(str2[i+1]-'a')*4+2;
a=('8'-str2[i+2])*2+1;
MAP[a][b]=str2[i]+32;
//printf("%c %d %d\n",MAP[a][b],a,b);
i=i+4;
}
else
{
b=(str2[i]-'a')*4+2;
a=('8'-str2[i+1])*2+1;
MAP[a][b]='p';
//printf("%c %d %d\n",MAP[a][b],a,b);
i=i+3;
}
}
//输出棋谱
for(i=0;i<17;i++)
{
if(i%2==0)
cout<<"+---+---+---+---+---+---+---+---+"<<endl;
else
{
for(j=0;j<33;j++)
{
if(j%4==0)
printf("|");
else if((j-1)%8==0||(j-3)%8==0)
{
if(t%2==0)
printf(".");
else
printf(":");
}
else if((j-5)%8==0||(j-7)%8==0)
{
if(t%2==0)
printf(":");
else
printf(".");
}
else
{
if(MAP[i][j])
printf("%c",MAP[i][j]);
else
{
if((j-2)%8==0)
{
if(t%2==0)
printf(".");
else
printf(":");
}
else
{
if(t%2==0)
printf(":");
else
printf(".");
}
}
}
}
printf("\n");
t++;
}
}
return 0;
}