## 12036 - Stable Grid

Moderator: Board moderators

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

### 12036 - Stable Grid

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

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

### Re: 12036 WA??

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

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