UVa 12036 Stable Grid (想法题)

2014-11-24 02:59:06 · 作者: · 浏览: 2

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


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


完整代码:

/*0.042s*/

#include
  
   
#include
   
     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; }