Page 1 of 1

12036 - Stable Grid

Posted: Sun Jul 31, 2011 4:27 pm
by tahmiid
helo...
i think there is something wrong in my logic. bt i cant figure it out. someone plz help me. here is my code (WA)...

Code: Select all

#include<stdio.h>

int main(void)
{
    long long int flag,t,n,arr[109][109],i,j,k,l,m;
    
    scanf("%lld", &t);
    
    for(i=1; i<=t; i++)
    {
        long long int count[109][109]={0};
        
        scanf("%lld", &n);
        
        for(j=0; j<n; j++)
        {
            for(k=0; k<n; k++)
            {
                scanf("%lld", &arr[j][k]);
                
                for(l=0; l<=109; l++)
                {   
                    for(m=0; m<=109; m++)
                    {      
                        if(arr[j][k]==arr[l][m])
                        {                        
                            count[l][m]++;
                            l=110;
                            break;
                        }
                    }
                }   
            }
        }
        flag=0;
        for(j=0; j<n; j++)
        {
            for(k=0; k<n; k++)
            {
                if(count[j][k]>n)
                {
                    flag=1;
                    j=110;
                    break;
                }
                
            }
        }
        if(flag==1)
        printf("Case %lld: no\n",i);
        else
        printf("Case %lld: yes\n",i);
    }
    return 0;
}

Re: 12036 WA??

Posted: Sun Aug 07, 2011 9:12 pm
by Mehadi
@tahmiid
I did not get ur procedure.I did not understand why u use n^4 when it can be solved only by counting?
Hope u will get it.

Re: 12036 WA??

Posted: Mon Aug 22, 2011 2:00 pm
by robot
please thinking easy....its a simple problem....
just think when a grid's in every column number is unique? Hints: u can count the unique number occurence...