2010-2011 ACM-ICPC Northeastern European Regional Contest (NEERC 10) G - Game of 10

人機對打.....

G-Game of 10

code:

#include<bits/stdc++.h>
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define inf 0x3f3f3f3f
using namespace std;
int num[20][20];
int r[20];
int c[20];
int rn[20];
int cn[20];
int main(){
	int x, y , i, j, k, z;
	memset(num, 0, sizeof(num));
	while(~scanf("%d%d%d", &x, &y, &z)){
		num[x][y] = z;
		r[x]+=z, c[y]+=z, rn[x]++, cn[y]++;
		bool flag=false;
		for(i=1; i<=4; i++){
			if(flag) break;
//			cout << "show :"<<rn[i]<<" "<<r[i]<<endl;
			if(rn[i]==3 && r[i]>5 && r[i]<10){
				flag=true;
				int index=1;
				while(num[i][index]) index++;
				cout << i <<" "<<index<<" "<<10-r[i]<<" WIN\n";
			} else if(cn[i]==3 && c[i]>5 && c[i]<10){
				flag=true;
				int index =1;
				while(num[index][i]) index++;
				cout<<index<<" "<<i<<" "<<10-c[i]<<" WIN\n";
			}
		}
		if(flag) break;
		num[x][5-y] = 5-z;
		r[x]+=5-z;
		c[5-y]+=5-z;
		rn[x]++;
		cn[5-y]++;
		cout << x<<" "<<5-y<<" "<<5-z<<endl;
	}
	return 0;
}




發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章