Emag eht htiw Em Pleh
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 2391 | Accepted: 1612 |
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.| +---+---+---+---+---+---+---+---+
这道题其实感觉就是把POJ2996又出了一遍,输入变输出,输出变输入,其实也是POJ2996的逆运算,先打8*8的表,将表中所有i+j得偶数的区域初始化为‘.’,奇数的初始化为‘:’,然后得到黑棋与白旗坐标,直接将棋的种类写入表的相应坐标位置,然后根据格式控制,输出即可AC此题,此题主要还是注意输入时候对字符串操作以及输出时候的格式控制,此处不是一般的坑,需要足够的耐心才可AC。
下面是AC代码:
#include<cstdio> #include<iostream> #include<cstring> using namespace std; char chess[35][35],ch[40],ch1; int main() { int i,j,x,y; scanf("%s",ch); scanf("%s",ch); memset(chess,'.',sizeof(chess)); for(i=1;i<=8;i++) for(j=1;j<=8;j++) if((i+j)%2==1) chess[i][j]=':'; i=0; while(i<strlen(ch)) { if(ch[i]>=97) { x=ch[i]+1-'a'; i++; y=9-(ch[i]-'0'); i+=2; chess[y][x]='P'; } else { ch1=ch[i]; i++; x=ch[i]+1-'a'; i++; y=9-(ch[i]-'0'); i+=2; chess[y][x]=ch1; } } scanf("%s",ch); scanf("%s",ch); i=0; while(i<strlen(ch)) { if(ch[i]>=97) { x=ch[i]+1-'a'; i++; y=9-(ch[i]-'0'); i+=2; chess[y][x]='p'; } else { ch1=ch[i]; i++; x=ch[i]+1-'a'; i++; y=9-(ch[i]-'0'); i+=2; chess[y][x]=ch1+32; } } for(i=1;i<=8;i++) if(i%2==1) printf("+---+---+---+---+---+---+---+---+\n|.%c.|:%c:|.%c.|:%c:|.%c.|:%c:|.%c.|:%c:|\n",chess[i][1],chess[i][2],chess[i][3],chess[i][4],chess[i][5],chess[i][6],chess[i][7],chess[i][8]); else printf("+---+---+---+---+---+---+---+---+\n|:%c:|.%c.|:%c:|.%c.|:%c:|.%c.|:%c:|.%c.|\n",chess[i][1],chess[i][2],chess[i][3],chess[i][4],chess[i][5],chess[i][6],chess[i][7],chess[i][8]); printf("+---+---+---+---+---+---+---+---+\n"); return 0; }