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,h6Sample 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.| +---+---+---+---+---+---+---+---+
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdio>
#include<climits>
using namespace std;
char map[18][34]={
"+---+---+---+---+---+---+---+---+",
"|:::|...|:::|...|:::|...|:::|...|",
"+---+---+---+---+---+---+---+---+",
"|...|:::|...|:::|...|:::|...|:::|",
"+---+---+---+---+---+---+---+---+",
"|:::|...|:::|...|:::|...|:::|...|",
"+---+---+---+---+---+---+---+---+",
"|...|:::|...|:::|...|:::|...|:::|",
"+---+---+---+---+---+---+---+---+",
"|:::|...|:::|...|:::|...|:::|...|",
"+---+---+---+---+---+---+---+---+",
"|...|:::|...|:::|...|:::|...|:::|",
"+---+---+---+---+---+---+---+---+",
"|:::|...|:::|...|:::|...|:::|...|",
"+---+---+---+---+---+---+---+---+",
"|...|:::|...|:::|...|:::|...|:::|",
"+---+---+---+---+---+---+---+---+"
};//上下颠倒制作地图,方便判断字母行数
char White[100],Black[100],Wnull[10],Bnull[10];
int main()
{
cin>>Wnull>>White>>Bnull>>Black;//输入
if(strcmp(Wnull,"Black:")==0)//如果先输入的Black则交换一下White[]和Black[]
{
char swap[100];
strcpy(swap,White);
strcpy(White,Black);
strcpy(Black,swap);
}
for(int i=0;;i++)
{
if(White[i*4]<='A'||White[i*4]>='Z')//若不是大写字母时跳出循环
break;
char c=White[i*4];//记录字母
int l=White[i*4+1]-'a';//记录字母的列数
int r=White[i*4+2]-'1';//记录字母的行数
map[r*2+1][l*4+2]=c;//把字母填入map
}
for(int i=strlen(White)-1;i>=0;i-=3)
{
int l=White[i-1]-'a';//记录P的列数
int r=White[i]-'1';//记录P的行数
map[r*2+1][l*4+2]='P';//将P填入map
if(i-5>=0&&White[i-5]>='A'&&White[i-5]<='Z')//若不是表示P的位置时跳出循环
break;
}
for(int i=0;;i++)
{
if(Black[i*4]<='A'||Black[i*4]>='Z')
break;
char c=Black[i*4]-'A'+'a';//同上
int l=Black[i*4+1]-'a';
int r=Black[i*4+2]-'1';
map[r*2+1][l*4+2]=c;
}
for(int i=strlen(Black)-1;i>=0;i-=3)
{
int l=Black[i-1]-'a';
int r=Black[i]-'1';
map[r*2+1][l*4+2]='p';
if(i-5>=0&&Black[i-5]>='A'&&Black[i-5]<='Z')
break;
}
for(int i=16;i>=0;i--) // 倒序输出
cout<<map[i]<<endl;
return 0;
}