Saturday, 2 June 2012

UVa 12036 Stable Grid Solution

#include <set>
#include <map>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <iostream>
#include <algorithm>
 
using namespace std;
 
int main()
{
    int n, i, j, t, tst, kase=1;
 
    scanf("%d",&tst);
 
    while ( tst-- )
    {
        scanf("%d",&n);
 
        int count[200]={0};
        bool valid = true;
        for (i=1 ; i<=n ; i++)
        {
            for (j=1 ; j<=n ; j++)
            {
                scanf("%d",&t);
                count[t]++;
                if (count[t]>n)
                {
                    valid=false;
                }
            }
        }
        if (valid) printf("Case %d: yes\n",kase++);
        else printf("Case %d: no\n",kase++);
 
    }
    return 0;
}

No comments:

Post a Comment