POJ 2996 Help Me with the Game(模拟)
来源:互联网 发布:淘宝联盟qq群推广步揍 编辑:程序博客网 时间:2024/05/21 04:22
http://poj.org/problem?id=2996
是在比赛的时候打的,当时想复杂了,题目没有读清楚。其实就是判断,大写为白棋,小写为黑棋。
#include<iostream>#include<algorithm>#include<cstdio>#include<vector>using namespace std;struct point{ int x,y;};point a1[105],b1[105];vector<point> a[30];vector<point> b[30];char s1[105],s[105],ss[]={'K','Q','R','B','N','P'};point k;void check1(int x,int j) //白色棋子 { k.x=8-x+1,k.y=j; a[s[j]-'A'].push_back(k);}void check2(int x,int j) //黑色棋子 { k.x=8-x+1,k.y=j; b[s[j]-'a'].push_back(k);}int cmp1(point p,point q){ if(p.x==q.x) return p.y<q.y; return p.x<q.x;} int cmp2(point p,point q){ if(p.x==q.x) return p.y<q.y; return p.x>q.x;}int main(){ cin>>s1; for(int q=1;q<=8;q++) { cin>>s>>s1; for(int j=2;j<=30;j+=4) { if(s[j]!=':'&&s[j]!='.') { if(s[j]>='A'&&s[j]<='Z') check1(q,j); else check2(q,j); } } } printf("White: "); for(int i=0;i<6;i++) { int cnt=0; for(int k=0;k<a[ss[i]-'A'].size();k++) a1[cnt++]=a[ss[i]-'A'][k]; sort(a1,a1+cnt,cmp1); for(int j=0;j<cnt;j++) { if(i!=5) printf("%c",ss[i]); printf("%c%d",(a1[j].y-2)/4+'a',a1[j].x); if(i!=5||j!=cnt-1) printf(","); } } printf("\nBlack: "); for(int i=0;i<6;i++) { int cnt=0; for(int k=0;k<b[ss[i]-'A'].size();k++) b1[cnt++]=b[ss[i]-'A'][k]; sort(b1,b1+cnt,cmp2); for(int j=0;j<cnt;j++) { if(i!=5) printf("%c",ss[i]); printf("%c%d",(b1[j].y-2)/4+'a',b1[j].x); if(i!=5||j!=cnt-1) printf(","); } } printf("\n"); return 0;}
阅读全文
0 0
- poj 2996 Help Me with the Game(模拟)
- POJ 2996Help Me with the Game(模拟)
- POJ 2996 Help Me with the Game(模拟)
- POJ 2996 Help Me with the Game(模拟)
- POJ 2996 Help Me with the Game 大模拟
- POJ 2996:Help Me with the Game 模拟题
- POJ 2996 Help Me with the Game (模拟)
- POJ 2996 Help Me with the Game 模拟
- poj 2996 Help Me with the Game(模拟)
- poj-2996-2993-Help Me with the Game-模拟法
- POJ 2996-Help Me with the Game(模拟)
- POJ 2996 Help Me with the Game 国际象棋,模拟
- 模拟 Help Me with the Game 2996
- Poj 2996 Help Me with the Game
- POJ 2996 Help Me with the Game
- poj 2996 Help Me with the Game
- poj 2996 Help Me with the Game
- POJ 2996 Help Me with the Game
- ASR---自动语音识别 概述
- Linux firewalld
- JavaScript-给字符串加千分符
- 并查集
- Foul Play UVA
- POJ 2996 Help Me with the Game(模拟)
- Linux下nodejs(一):UEditor 使用
- CSS中清除浮动的方式探究
- SLF4J: Class path contains multiple SLF4J bindings.
- Codeforces
- HTTP协议—— 简单认识TCP/IP协议
- Android将Excel表格解析成json文件
- POJ 2993 Emag eht htiw Em Pleh(模拟)
- Listener等外部类获取Spring Bean