Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:测试数据-对应输出

Posted by langx at 2010-10-07 16:26:21 on Problem 1970 and last updated at 2010-10-07 16:41:59
In Reply To:测试数据-输入 Posted by:langx at 2010-10-07 16:25:55
1
3 2

0

1
8 3

0

2
2 2

1
19 1

2
15 19


-------------------------
Problem: 1970		User: langx
Memory: 200K		Time: 0MS
Language: C++		Result: Accepted

-------------------------
#include <iostream>
#include <cstdlib>
using namespace std;

int t,renju[20][20];

bool TestConsecutive(int l,int u){
	int p, q, player = renju[l][u];
	q = u;
	while( ++q < 20 && renju[l][q] == player && q - u < 7); 
	if(q - u == 5 && (u == 1 || (u > 1 &&renju[l][u - 1] != player))) 
		return true;
	p = l;
	while( ++p < 20 && renju[p][u] == player && p - l < 7); 
	if(p - l == 5 && (l == 1 || (l > 1 &&renju[l - 1][u] != player)))
		return true;  
	q = u;p = l;
	while( --p > 0 && ++q < 20 && renju[p][q] == player && q - u < 7);
	if(q - u == 5 && (l == 19 || u == 1 ||(l < 19 && u > 1 &&
		renju[l + 1][u - 1] != player)))
		return true;
	q = u;p = l; 
	while( ++p < 20 && ++q < 20 && renju[p][q] == player && p - l < 7);
	if(p - l == 5 && (l == 1 || u == 1 ||(l > 1 && u > 1 &&
		renju[l - 1][u - 1] != player)))
		return true;
	return false;
}

int WhoWon(int &ix,int &jx){
	for (int i = 1; i < 20; ++i ) {
		for (int j = 1; j < 20; ++j ) {
			if(renju[i][j] && TestConsecutive(i,j)){
				ix = i; jx = j;
				return renju[i][j];
			}
		}
	}
	return 0;
}

int main(){
	int i, j, k;
	scanf("%d",&t);
	while ( t-- ) {
		for ( i = 1; i < 20; ++i ) {
			for ( j = 1; j < 20; ++j ) {
				scanf("%d",&renju[i][j]);
			}
		}
		k = WhoWon(i,j);
		printf("%d\n",k);
		if( k != 0)
			printf("%d %d\n",i,j);
	}
	system("pause");
	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator