## 11244 - Counting Stars

Moderator: Board moderators

rongtuli
New poster
Posts: 5
Joined: Fri Aug 17, 2007 4:38 am

### 11244 - Counting Stars

hi,
i can not find out the bug in my program.why the online judge treat my program as WA. can anyone give me some output for the problem.
by tulip

Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Contact:
Did you check the boundary cases carefully? However, you can post your code.
Ami ekhono shopno dekhi...
HomePage

rongtuli
New poster
Posts: 5
Joined: Fri Aug 17, 2007 4:38 am
thank u jan bhai i checked the boundary. but anyway i reprogrammed it in another way and already got AC.
by tulip

rossi kamal
New poster
Posts: 14
Joined: Mon Sep 03, 2007 10:11 am
Contact:

### 11244 wa

i have removed each steps result with an array v[][].-that will not allow the future result changed

still cannot understand why i am getting wrong answer ..

rossi kamal
New poster
Posts: 14
Joined: Mon Sep 03, 2007 10:11 am
Contact:
/*
Rossi Kamal
acm id 26373
prb id 11244
simple grid

*/

#include<stdio.h>
int check(int x,int y);
char a[205][205];
int v[205][205];
int helper[8][2]={-1,-1,-1,0,-1,+1,1,+1,+1,+1,+1,0,+1,-1,0,-1 };

int main()
{

//freopen("in11244.txt","r",stdin);
int res,i,j,row,column;

while(scanf("%d %d\n",&row,&column)==2 )
{
int c=0;
if(row==0 && column==0)
break;

for(i=0;i<row;i++)
gets(a);

for(i=0;i<row;i++)
for(j=0;j<column;j++)
v[j]=1;

for(i=0;i<row;i++)
for(j=0;j<column;j++)
if(a[j]=='*')
{
res=check(i,j);
if(res==1)
{

c++;

}
}

for(i=0;i<row;i++)
for(j=0;j<column;j++)
v[j]=0;

printf("%d\n",c);

}

return 0;
}

int check(int xx,int yy)
{
int ii;
for(ii=0;ii<8;ii++)
{
int aa,bb;
aa=xx+helper[ii][0];
bb=yy+helper[ii][1];

if(v[aa][bb]==1&&a[aa][bb]=='*')
return 0;

}

return 1;
}

here is my code

mmonish
Experienced poster
Posts: 109
Joined: Sun Mar 11, 2007 2:55 pm
Location: SUST
I think this portion of ur code is not correct.

Code: Select all

``int helper[8][2]={-1,-1,-1,0,-1,+1,1,+1,+1,+1,+1,0,+1,-1,0,-1 };``
Hope this helps.

Obaida
A great helper
Posts: 380
Joined: Wed Jan 16, 2008 6:51 am

### Re: 11244 - Counting Stars

I don't know why I am getting Wrong Answer.! I think I checked all the things.

Code: Select all

``Removed``
Last edited by Obaida on Thu May 29, 2008 10:53 am, edited 1 time in total.
try_try_try_try_&&&_try@try.com
This may be the address of success.

rio
A great helper
Posts: 385
Joined: Thu Sep 21, 2006 5:01 pm
Location: Kyoto, Japan

### Re: 11244 - Counting Stars

Read the problem description more carefully.
You have misunderstood the definition of star.

-----
Rio

Obaida
A great helper
Posts: 380
Joined: Wed Jan 16, 2008 6:51 am

### Re: 11244 - Counting Stars

Can you explain it to me??? I again got WA...!!!
try_try_try_try_&&&_try@try.com
This may be the address of success.

rio
A great helper
Posts: 385
Joined: Thu Sep 21, 2006 5:01 pm
Location: Kyoto, Japan

### Re: 11244 - Counting Stars

Well, there is nothing to explain.
The problem statement is written clearly enough. There is no word to add.

-----
Rio

Obaida
A great helper
Posts: 380
Joined: Wed Jan 16, 2008 6:51 am

### Re: 11244 - Counting Stars

I don't know why this time I got WA!!!

Code: Select all

``Thanks rio Now Accepted.``
Last edited by Obaida on Sat May 31, 2008 11:43 am, edited 1 time in total.
try_try_try_try_&&&_try@try.com
This may be the address of success.

rio
A great helper
Posts: 385
Joined: Thu Sep 21, 2006 5:01 pm
Location: Kyoto, Japan

### Re: 11244 - Counting Stars

Look over your code few more times.
Its an obvious mistake. Not hard to find.

-----
Rio

Obaida
A great helper
Posts: 380
Joined: Wed Jan 16, 2008 6:51 am

### Re: 11244 - Counting Stars

I am really sorry rio.
That was happening for my careless checking. I can't even think about it.
It was a foul mistake. Thank you.
try_try_try_try_&&&_try@try.com
This may be the address of success.

Obaida
A great helper
Posts: 380
Joined: Wed Jan 16, 2008 6:51 am

### Re: 11244 - Counting Stars

what type of language it is????
try_try_try_try_&&&_try@try.com
This may be the address of success.

calicratis19
Learning poster
Posts: 76
Joined: Mon Jul 21, 2008 8:50 am