UVa 12036 - Stable Grid Solution

#include <iostream>
#include <vector>
using namespace std;
int main(){
    ios::sync_with_stdio(0);
    int t,cs=0;
    cin>>t;
    while(t--){
        int flag=0;
        cout<<"Case "<<++cs<<": ";
        int n;
        cin>>n;
        vector<int> a(101);
        for(int i=0;i<n;i++)
            for(int j=0;j<n;j++){
                int x;
                cin>>x;
                a[x]++;
                if(a[x]>n)
                    flag=1;
            }
        if(flag)
            cout<<"no"<<endl;
        else
            cout<<"yes"<<endl;
    }
}

Comments