Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 3292 | Accepted: 2122 |
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
脑残模拟!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
AC代码如下:
#include<iostream> #include<cstdio> using namespace std; int main() { char map[50][50]; int Ph[20],ph[20]; int Rt,rt,Bt,bt,Nt,nt,Pt,pt,Kt,kt,Qt,qt; int Rh[20],rh[20],Bh[20],bh[20],Nh[20],nh[20]; char Rz[20],rz[20],Bz[20],bz[20],Nz[20],nz[20],Pz[20],pz[20]; int Kh,kh,Qh,qh; char Kz,kz,Qz,qz; int i,j; for(i=0;i<17;i++) cin>>map[i]; Rt=rt=Bt=bt=Nt=nt=Pt=pt=Kt=kt=Qt=qt=0; for(i=1;i<17;i+=2) { for(j=2;j<33;j+=4) { if(map[i][j]=='k') {kh=8-i/2;kz=(char)j/4+'a';kt++;} if(map[i][j]=='q') {qh=8-i/2;qz=(char)j/4+'a';qt++;} if(map[i][j]=='r') {rh[rt]=8-i/2;rz[rt]=(char)j/4+'a';rt++;} if(map[i][j]=='b') {bh[bt]=8-i/2;bz[bt]=(char)j/4+'a';bt++;} if(map[i][j]=='n') {nh[nt]=8-i/2;nz[nt]=(char)j/4+'a';nt++;} if(map[i][j]=='p') {ph[pt]=8-i/2;pz[pt]=(char)j/4+'a';pt++;} } } for(i=15;i>=1;i-=2) { for(j=2;j<33;j+=4) { if(map[i][j]=='K') {Kh=8-i/2;Kz=(char)j/4+'a';Kt++;} if(map[i][j]=='Q') {Qh=8-i/2;Qz=(char)j/4+'a';Qt++;} if(map[i][j]=='R') {Rh[Rt]=8-i/2;Rz[Rt]=(char)j/4+'a';Rt++;} if(map[i][j]=='B') {Bh[Bt]=8-i/2;Bz[Bt]=(char)j/4+'a';Bt++;} if(map[i][j]=='N') {Nh[Nt]=8-i/2;Nz[Nt]=(char)j/4+'a';Nt++;} if(map[i][j]=='P') {Ph[Pt]=8-i/2;Pz[Pt]=(char)j/4+'a';Pt++;} } } cout<<"White: "; if(Kt!=0) cout<<"K"<<Kz<<Kh<<","; if(Qt!=0) cout<<"Q"<<Qz<<Qh<<","; for(i=0;i<Rt;i++) cout<<"R"<<Rz[i]<<Rh[i]<<","; for(i=0;i<Bt;i++) cout<<"B"<<Bz[i]<<Bh[i]<<","; for(i=0;i<Nt;i++) cout<<"N"<<Nz[i]<<Nh[i]<<","; for(i=0;i<Pt;i++) if(i!=Pt-1) cout<<Pz[i]<<Ph[i]<<","; else cout<<Pz[i]<<Ph[i]<<endl; cout<<"Black: "; if(kt!=0) cout<<"K"<<kz<<kh<<","; if(qt!=0) cout<<"Q"<<qz<<qh<<","; for(i=0;i<rt;i++) cout<<"R"<<rz[i]<<rh[i]<<","; for(i=0;i<bt;i++) cout<<"B"<<bz[i]<<bh[i]<<","; for(i=0;i<nt;i++) cout<<"N"<<nz[i]<<nh[i]<<","; for(i=0;i<pt;i++) if(i!=pt-1) cout<<pz[i]<<ph[i]<<","; else cout<<pz[i]<<ph[i]<<endl; return 0; }
POJ 2996 Help Me with the Game,布布扣,bubuko.com
POJ 2996 Help Me with the Game
原文地址:http://blog.csdn.net/hanhai768/article/details/37562203