Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 2572 | Accepted: 1667 |
Description
Input
Output
Sample Input
+---+---+---+---+---+---+---+---+ |.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.| +---+---+---+---+---+---+---+---+
Sample Output
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
Source
#include<iostream> #include<cstdio> #include<map> #include<algorithm> using namespace std; int bnum,wnum; struct node { char c,x; int y; int q; }b[40],w[40]; char a[40][40]; bool wcmp(node n1,node n2) { if(n1.q==n2.q) { if(n1.y==n2.y)return n1.x<n2.x; else return n1.y<n2.y; } else return n1.q<n2.q; } bool bcmp(node n1,node n2) { if(n1.q==n2.q) { if(n1.y==n2.y)return n1.x<n2.x; else return n1.y>n2.y; } else return n1.q<n2.q; } int main() { map<char,int>p; p['K']=0; p['Q']=1; p['R']=2; p['B']=3; p['N']=4; p['P']=5; bnum=0; wnum=0; for(int i=0;i<17;i++)scanf("%s",&a[i]); for(int i=0;i<8;i++) { for(int j=0;j<8;j++) { int xx=2*i+1; int yy=4*j+2; if(a[xx][yy]>='A'&&a[xx][yy]<='Z') { w[wnum].c=a[xx][yy]; w[wnum].x='a'+j; w[wnum].y=8-i; w[wnum].q=p[w[wnum].c]; wnum++; } else if(a[xx][yy]>='a'&&a[xx][yy]<='z') { b[bnum].c=a[xx][yy]-32; b[bnum].x='a'+j; b[bnum].y=8-i; b[bnum].q=p[b[bnum].c]; bnum++; } } } sort(w,w+wnum,wcmp); sort(b,b+bnum,bcmp); cout<<"White: "; if(w[0].c=='P')cout<<w[0].x<<w[0].y; else cout<<w[0].c<<w[0].x<<w[0].y; for(int i=1;i<wnum;i++) { if(w[i].c=='P')cout<<","<<w[i].x<<w[i].y; else cout<<","<<w[i].c<<w[i].x<<w[i].y; } cout<<endl; cout<<"Black: "; if(b[0].c=='P')cout<<b[0].x<<b[0].y; else cout<<b[0].c<<b[0].x<<b[0].y; for(int i=1;i<bnum;i++) { if(b[i].c=='P')cout<<","<<b[i].x<<b[i].y; else cout<<","<<b[i].c<<b[i].x<<b[i].y; } cout<<endl; return 0; }