比赛 HAOI2009 模拟试题4 评测结果 AAAAAWWWWA
题目名称 K- 联赛 最终得分 60
用户昵称 BYVoid 运行时间 0.000 s
代码语言 C++ 内存使用 0.00 MiB
提交时间 2009-04-24 10:34:13
显示代码纯文本
/* 
 * Problem: HAOI2009 模拟4 kleague
 * Author: Guo Jiabao
 * Time: 2009.4.24 10:10
 * State: Unsolved
 * Memo: 模拟
*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
const int MAXN=26;
using namespace std;
struct state
{
	int Win[MAXN],Def[MAXN];
}S,T;
int com[MAXN][MAXN];
int N,Lc,List[MAXN];
void init()
{
	int i,j;
	freopen("kleague.in","r",stdin);
	freopen("kleague.out","w",stdout);
	scanf("%d",&N);
	for (i=1;i<=N;i++)
		scanf("%d%d",&S.Win[i],&S.Def[i]);
	for (i=1;i<=N;i++)
	{
		for (j=1;j<=N;j++)
		{
			scanf("%d",&com[i][j]);
		}
	}
}
bool make(int i,int less,int p)
{
	int j,fx,fy;
	for (j=1;j<=N;j++)
	{
		if (j==p) continue;
		fx=com[i][j]/2;
		if (i>j)
			fx=com[i][j] - fx;
		while (fx > 0 && T.Win[j] + 1 <= less)
		{
			T.Win[i] --;
			T.Win[j] ++;
			fx--;
			if (T.Win[i]<=less)
				return true;
		}
	}
	return false;
}
void solve()
{
	int i,j,k,p,q;
	for (i=1;i<=N;i++)
	{
		T=S;Lc=0;
		for (j=1;j<=N;j++)
		{
			T.Win[i] += com[i][j];
			T.Def[j] += com[i][j];
		}
		for (j=1;j<=N;j++)
		{
			if (i==j) continue;
			for (k=j+1;k<=N;k++)
			{
				if (k==i) continue;
				p=com[j][k]/2; q=com[j][k] - p;
				T.Win[j] += p; T.Def[j] += q;
				T.Win[k] += q; T.Def[j] += p;
			}
			if (T.Win[j] > T.Win[i])
				List[++Lc]=j;
		}
		for (j=1;j<=Lc;j++)
		{
			k=List[j]; //k is more
			if (!make(k,T.Win[i],i))
				break;
		}
		if (j>Lc)
			printf("%d ",i);
	}
}
int main()
{
	init();
	solve();
	return 0;
}