12036 - Stable Grid

All about problems in Volume 120. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Post Reply
tahmiid
New poster
Posts: 1
Joined: Sun Jul 31, 2011 4:18 pm

12036 - Stable Grid

Post by tahmiid » Sun Jul 31, 2011 4:27 pm

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

Mehadi
New poster
Posts: 18
Joined: Sun Jan 24, 2010 11:17 am

Re: 12036 WA??

Post by Mehadi » Sun Aug 07, 2011 9:12 pm

@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.

robot
New poster
Posts: 29
Joined: Sun May 24, 2009 8:39 pm

Re: 12036 WA??

Post by robot » Mon Aug 22, 2011 2:00 pm

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...

Post Reply

Return to “Volume 120 (12000-12099)”