#include #include #include using namespace std; int CH[500]; int CHZ[10]; #define PII pair #define PIII pair #define Piii(a,b,c) PIII(a,PII(b,c)) #define SIII set #define fi first #define se second int main(void) { SIII BLE,WHI; CH['K'-0]=0;CH['k'-0]=0;CHZ[0]='K'; CH['Q'-0]=1;CH['q'-0]=1;CHZ[1]='Q'; CH['R'-0]=2;CH['r'-0]=2;CHZ[2]='R'; CH['B'-0]=3;CH['b'-0]=3;CHZ[3]='B'; CH['N'-0]=4;CH['n'-0]=4;CHZ[4]='N'; CH['P'-0]=5;CH['p'-0]=5;CHZ[5]='P'; char S[100][100]; for(int i=0; i<17; i++) gets(S[16-i]); for (int r=0; r<8; r++) for (int s=0; s<8; s++) { char ch=S[2*r+1][4*s+2]; int v=CH[ch-0]; if (ch>='a' && ch<='z') BLE.insert(Piii(v,-r,s)); if (ch>='A' && ch<='Z') WHI.insert(Piii(v,r,s)); } printf("White: "); for (SIII::iterator it=WHI.begin(); it!=WHI.end(); it++) { if (it!=WHI.begin()) printf(","); if (it->fi!=5) printf("%c", CHZ[it->fi]); printf("%c%d", it->se.se+'a', it->se.fi+1); } printf("\n"); printf("Black: "); for (SIII::iterator it=BLE.begin(); it!=BLE.end(); it++) { if (it!=BLE.begin()) printf(","); if (it->fi!=5) printf("%c", CHZ[it->fi]); printf("%c%d", it->se.se+'a', -it->se.fi+1); } printf("\n"); return 0; }