Welcome

首页 / 软件开发 / 数据结构与算法 / UVa 12036 Stable Grid:想法题

UVa 12036 Stable Grid:想法题2014-07-07 synapse7

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

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

完整代码:

01./*0.042s*/02.03.#include<cstdio>04.#include<cstring>05.06.int cnt[105], n;07.08.bool judge()09.{10.bool f = true;11.int i, j, k;12.for (i = 0; i < n; ++i)13.{14.for (j = 0; j < n; ++j)15.{16.scanf("%d", &k);17.++cnt[k];18.if (cnt[k] > n) f = false;19.}20.}21.return f;22.}23.24.int main()25.{26.int T, cas = 0;27.scanf("%d", &T);28.while (T--)29.{30.scanf("%d", &n);31.memset(cnt, 0, sizeof(cnt));32.printf("Case %d: %s
", ++cas, (judge() ? "yes" : "no"));33.}34.return 0;35.}