uva141
来源:互联网 发布:吴江js华腾公寓自提柜 编辑:程序博客网 时间:2024/06/08 08:57
#include <iostream>#include <stdio.h>#include <string.h>#include <map>using namespace std;string s,s1,s2,s3;int move_;map<string,int> m;int n;void equal_string(int t){ m[s]++; if(m[s]==2) move_=t+1; s1=s; s2=s; s3=s; if(m[s]>=2) move_=t+1; for(int i=0; i<n; i++) for(int j=0; j<n; j++) s1[j*n+n-i-1]=s[i*n+j]; for(int i=0; i<n; i++) for(int j=0; j<n; j++) s2[(n-i-1)*n+n-j-1]=s[i*n+j]; for(int i=0; i<n; i++) for(int j=0; j<n; j++) s3[(n-j-1)*n+i]=s[i*n+j]; if(s!=s1) m[s1]++; if(s!=s2 && s1!=s2) m[s2]++; if(s!=s3 && s1!=s3 && s2!=s3) m[s3]++; if(m[s1]==2) move_=t+1; if(m[s2]==2) move_=t+1; if(m[s3]==2) move_=t+1;}int main(){ while(scanf("%d",&n),n) { move_=0; m.clear(); s.clear(); for(int t=0; t<n*n; t++) s.push_back('0');//这个bug找了好久……不能用数组形式 for(int i=0; i<2*n; i++) { int a,b; char c; scanf("%d%d %c",&a,&b,&c); if(c=='+') s[(a-1)*n+b-1]='1'; else s[(a-1)*n+b-1]='0'; equal_string(i); } if(move_) printf("Player %d wins on move %d\n",move_%2+1,move_); else printf("Draw\n"); } return 0;}
阅读全文
0 0
- uva141
- uva141
- uva141 - The Spot Game
- [哈希]The Spot Game uva141
- uva141 - The Spot Game(斑点游戏)
- UVA141- The Spot Game【运行时间:25ms】
- MyBatis中$和#的区别
- 阻塞模式下socket连接connect超时后长达75秒,如何避免
- SSM实现简单的CRUD技术分析
- 静态工厂模式&工厂模式&抽象工厂模式&解决的问题
- mybatis 中 foreach collection的三种用法
- uva141
- 2017-11-4离线赛总结
- Dalvik指令解析示例
- Tomcat7.0.42源码研读之组件生命周期Lifecycle(一)
- 动态规划之最长公共子序列
- C
- 51Nod
- 你真的了解过度绘制吗?
- 使用gdb调试的一般步骤