UVa 12036 Stable Grid (想法题)

原创 2013年12月03日 18:12:45

http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=3187


表示想复杂了。。其实只要统计是否有一个数字出现大于n次就no啊orz


完整代码:

/*0.042s*/

#include<cstdio>
#include<cstring>

int cnt[105], n;

bool judge()
{
	bool f = true;
	int i, j, k;
	for (i = 0; i < n; ++i)
	{
		for (j = 0; j < n; ++j)
		{
			scanf("%d", &k);
			++cnt[k];
			if (cnt[k] > n) f = false;
		}
	}
	return f;
}

int main()
{
	int T, cas = 0;
	scanf("%d", &T);
	while (T--)
	{
		scanf("%d", &n);
		memset(cnt, 0, sizeof(cnt));
		printf("Case %d: %s\n", ++cas, (judge() ? "yes" : "no"));
	}
	return 0;
}

相关文章推荐

UVA - 12036 Stable Grid

Description  Stable Grid  Consider a grid of size n x n where each cell cont...

UVa 10152 ShellSort (想法题)

10152 - ShellSort Time limit: 3.000 seconds  http://uva.onlinejudge.org/index.php?option=com_onlinej...

CERC 2004 / UVa 1335 Beijing Guards (二分&贪心&想法题)

1335 - Beijing Guards Time limit: 3.000 seconds  http://uva.onlinejudge.org/index.php?option=com_onl...

World Finals 2004 / UVa 1030 Image Is Everything (想法题&迭代更新)

1030 - Image Is Everything Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com...

UVa 757 / POJ 1042 / East Central North America 1999 Gone Fishing (枚举&贪心&想法题&优先队列)

757 - Gone Fishing Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinej...

UVa 12400 - 3, 2, 1, 0 (数学想法题&高精度 or 打表)

http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&p...

UVA 1450 Airport(二分+想法题)

题意: 有一个飞机场,有两条待飞跑到w和e,一条起飞跑道,每一时刻只能起飞一架飞机,然后有w[i]和e[i]架飞机进入w和e跑道,飞机编号从0开始,问说如何安排起飞可以使得飞机编号的最大值最小。 ...

UVa 696 How Many Knights (想法题)

696 - How Many Knights Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=online...

UVa 11489 Integer Game (博弈&想法题)

11489 - Integer Game Time limit: 1.000 seconds http://uva.onlinejudge.org/index.php?option=com_onl...

UVa 278 Chess (想法题)

278 - Chess Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:UVa 12036 Stable Grid (想法题)
举报原因:
原因补充:

(最多只允许输入30个字)