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

是因为数据太弱吗,照感觉写了一下竟然过了

Posted by uuuouou at 2014-12-24 22:04:34 on Problem 2941
#include <cstdio>

int n, arr[1000][1000];
int leftUpToRightDown(int c)
{
	int i = (c+1) % n, j = 1, res = arr[0][c];
	while(i != c){
		res += arr[j++][i];
		if(++i == n) i = 0;
	}
	return res;
}
int rightUpToLeftDown(int c)
{
	int i = (c-1+n) % n, j = 1, res = arr[0][c];
	while(i != c){
		res += arr[j++][i];
		if(--i < 0) i = n-1;
	}
	return res;
}
bool check()
{
	int sum = leftUpToRightDown(0);
	for(int i = 1; i < n; ++i){
		if(sum != leftUpToRightDown(i)) return false;
	}
	for(int i = n-1; i > -1; --i){
		if(sum != rightUpToLeftDown(i)) return false;
	}
	return true;
}

int main()
{
	while(scanf("%d", &n), n){
		for(int i = 0; i < n; ++i)
			for(int j = 0; j < n; ++j) scanf("%d", arr[i]+j);
		if(check()) puts("homogeneous");
		else puts("not homogeneous");
	}
	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