模拟 + 打表 --- Emag eht htiw Em Pleh
Emag eht htiw Em Pleh
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 2578 | Accepted: 1731 |
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.| +---+---+---+---+---+---+---+---+
【题目来源】
【题目大意】
这题和上一题是相关联的,上一题是给棋盘让你输出棋子的坐标,这题时给坐标让你输出棋盘。
【题目分析】
先将整个棋盘的初始状态打表存放起来,然后每次都初始化,输入坐标后更新数组的值,最后输出。
思路清晰就能1A。
#include<cstdio> #include<cstring> char Map[17][33]; char Graph[17][33]= { '+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+', '|','.','.','.','|',':',':',':','|','.','.','.','|',':',':',':','|','.','.','.','|',':',':',':','|','.','.','.','|',':',':',':','|', '+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+', '|',':',':',':','|','.','.','.','|',':',':',':','|','.','.','.','|',':',':',':','|','.','.','.','|',':',':',':','|','.','.','.','|', '+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+', '|','.','.','.','|',':',':',':','|','.','.','.','|',':',':',':','|','.','.','.','|',':',':',':','|','.','.','.','|',':',':',':','|', '+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+', '|',':',':',':','|','.','.','.','|',':',':',':','|','.','.','.','|',':',':',':','|','.','.','.','|',':',':',':','|','.','.','.','|', '+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+', '|','.','.','.','|',':',':',':','|','.','.','.','|',':',':',':','|','.','.','.','|',':',':',':','|','.','.','.','|',':',':',':','|', '+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+', '|',':',':',':','|','.','.','.','|',':',':',':','|','.','.','.','|',':',':',':','|','.','.','.','|',':',':',':','|','.','.','.','|', '+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+', '|','.','.','.','|',':',':',':','|','.','.','.','|',':',':',':','|','.','.','.','|',':',':',':','|','.','.','.','|',':',':',':','|', '+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+', '|',':',':',':','|','.','.','.','|',':',':',':','|','.','.','.','|',':',':',':','|','.','.','.','|',':',':',':','|','.','.','.','|', '+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+','-','-','-','+', }; void make_table() { for(int i=0;i<17;i++) for(int j=0;j<33;j++) Map[i][j]=Graph[i][j]; } char w[500]; char b[500]; void update1(char c,char x1,char y1) { int x=(8-(y1-'0')+1)*2-1; int y=(x1-'a'+1)*4-2; Map[x][y]=c; } void update2(char c,char x1,char y1) { int x=(8-(y1-'0')+1)*2-1; int y=(x1-'a'+1)*4-2; Map[x][y]=c+32; } void update3(char x1,char y1) { int x=(8-(y1-'0')+1)*2-1; int y=(x1-'a'+1)*4-2; Map[x][y]='P'; } void update4(char x1,char y1) { int x=(8-(y1-'0')+1)*2-1; int y=(x1-'a'+1)*4-2; Map[x][y]='p'; } int main() { while(scanf("White: %s",w)!=EOF) { getchar(); scanf("Black: %s",b); getchar(); make_table(); int len1=strlen(w); int len2=strlen(b); for(int i=0;i<len1;) { if(w[i]>='A'&&w[i]<='Z') { update1(w[i],w[i+1],w[i+2]); i+=4; } else if(w[i]>='a'&&w[i]<='z') { update3(w[i],w[i+1]); i+=3; } } for(int i=0;i<len2;) { if(b[i]>='A'&&b[i]<='Z') { update2(b[i],b[i+1],b[i+2]); i+=4; } else if(b[i]>='a'&&b[i]<='z') { update4(b[i],b[i+1]); i+=3; } } for(int i=0;i<17;i++) { for(int j=0;j<33;j++) printf("%c",Map[i][j]); puts(""); } } return 0; }