926 - Walking Around Wisely

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

Moderator: Board moderators

User avatar
joeluchoa
New poster
Posts: 28
Joined: Sat Jul 31, 2004 12:11 am
Location: Brasil

926 - Walking Around Wisely

Post by joeluchoa » Mon Oct 23, 2006 4:11 am

I' ve got WA and don't see my error!

This is my code:

Code: Select all

Removed after AC
Can somebody help me?
Last edited by joeluchoa on Mon Oct 23, 2006 5:38 pm, edited 1 time in total.
http://acm.uva.es/problemset/usersnew.php?user=47903

All men are like grass,and all their
glory is like the flowers of the field;
the grass withers and the flowers fall,
but the word of the Lord stands forever.
[1 Peter 1:24-25]

User avatar
joeluchoa
New poster
Posts: 28
Joined: Sat Jul 31, 2004 12:11 am
Location: Brasil

Post by joeluchoa » Mon Oct 23, 2006 5:38 pm

I've got AC now! :D
http://acm.uva.es/problemset/usersnew.php?user=47903

All men are like grass,and all their
glory is like the flowers of the field;
the grass withers and the flowers fall,
but the word of the Lord stands forever.
[1 Peter 1:24-25]

nymo
Experienced poster
Posts: 149
Joined: Sun Jun 01, 2003 8:58 am
Location: :)

SOME I/O, please:

Post by nymo » Sat Oct 28, 2006 6:36 pm

Code: Select all

input:
====
4
3
1 1
3 3
2
2 3 S
2 2 W
3
1 1
3 3
0
3
1 1
1 1
0
30
1 1
30 30
0
my output is:

Code: Select all

3
6
1
51542064 /* This output is wrong due to 32-bit integer */
is it correct? I am getting WA. Can somebody post some more IO and check mine??? please. thanks :)
Last edited by nymo on Sat Oct 28, 2006 10:14 pm, edited 1 time in total.

Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh
Contact:

Post by Jan » Sat Oct 28, 2006 7:34 pm

My accepted code returns
Output:

Code: Select all

3
6
1
30067266499541040
So, use 64-bit int.
Ami ekhono shopno dekhi...
HomePage

nymo
Experienced poster
Posts: 149
Joined: Sun Jun 01, 2003 8:58 am
Location: :)

Post by nymo » Sat Oct 28, 2006 8:09 pm

to Jan, now I 've used long long and get the same result as you provided. but still WA. can you provide some more IO?

Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh
Contact:

Post by Jan » Sat Oct 28, 2006 9:50 pm

You can try the following i/o set
Input:

Code: Select all

3
3
1 1
3 3
3
2 3 S
2 2 W
1 1 E
3
2 1
2 3
0
10
5 5
8 6
3
5 5 N
5 6 E
8 5 E
Output:

Code: Select all

1
1
3
Hope it helps.
Ami ekhono shopno dekhi...
HomePage

nymo
Experienced poster
Posts: 149
Joined: Sun Jun 01, 2003 8:58 am
Location: :)

Thanks Jan

Post by nymo » Sat Oct 28, 2006 10:12 pm

Thanks Jan, got ACC, there was small mistake in the initialization part. :oops:
regards,
nymo

shakil
Learning poster
Posts: 74
Joined: Sat Jul 15, 2006 6:28 am
Location: CUET , bangladesh
Contact:

Post by shakil » Tue Nov 13, 2007 4:28 pm

Why WA????

Code: Select all

#include<stdio.h>
long long sa[39][39],A[39][39][3],i,j,x,y,X,Y,a,b,test,n,m;
char temp[10];


int main()
{

scanf("%lld",&test);

while(test--)
{

scanf("%lld",&n);
for(i=0;i<=n;i++)
for(j=0;j<=n;j++)
{sa[i][j]=0;
 for(a=0;a<2;a++)
	 A[i][j][a]=0;
}

scanf("%lld",&x);
scanf("%lld",&y);
sa[x][y]=1;
scanf("%lld",&X);
scanf("%lld",&Y);
//scanf("%I64d %I64d",&X,&Y);

scanf("%lld",&m);
for(i=0;i<m;i++)
{
scanf("%lld %lld %s",&a,&b,temp);
if(temp[0]=='S')
A[a-1][b][0]=1;
else if(temp[0]=='W')
A[a][b-1][1]=1;
else if(temp[0]=='E')
A[a][b][1]=1;
else if(temp[0]=='N')
A[a][b][0]=1;

}


for(i=x;i<=X;i++)
for(j=y;j<=Y;j++)
if(sa[i][j]!=0)
{
if(A[i][j][0]==0)
sa[i+1][j]+=sa[i][j];
if(A[i][j][1]==0)
sa[i][j+1]+=sa[i][j];
}
printf("%lld\n",sa[X][Y]);

}


return 0;
}
SHAKIL

howardcheng
Learning poster
Posts: 71
Joined: Thu Aug 21, 2003 1:56 am

Re: 926 - Walking Around Wisely

Post by howardcheng » Thu Jun 05, 2008 8:24 pm

I can't figure out what is wrong with my code (keeps getting WA). It's been a while since I have done these problems. Help please? Thanks.

Code: Select all

#include <stdio.h>
#include <assert.h>

#define MAX_N 30

int main(void)
{
  int C, N, Ax, Ay, Bx, By, W;
  int x, y;

  /* whether an intersection is blocked from W or S */
  int blockW[MAX_N+1][MAX_N+1], blockS[MAX_N+1][MAX_N+1];
  char dir;

  unsigned long long ways[MAX_N+1][MAX_N+1];

  scanf("%d", &C);
  while (C-- > 0) {
    scanf("%d %d %d %d %d", &N, &Ax, &Ay, &Bx, &By);
    
    assert(1 < N && N <= 30 && Ax <= Bx && Ay <= By);
    for (x = 1; x <= N; x++) {
      for (y = 1; y <= N; y++) {
	blockW[x][y] = blockS[x][y] = 0;
      }
    }
    scanf("%d", &W);
    while (W-- > 0) {
      scanf("%d %d %c", &x, &y, &dir);
      switch (dir) {
      case 'N':
	blockS[x][y+1] = 1;
	break;
      case 'S':
	blockS[x][y] = 1;
	break;
      case 'E':
	blockW[x+1][y] = 1;
	break;
      case 'W':
	blockW[x][y] = 1;
	break;
      default:
	assert(0);
      }
    }

    ways[Ax][Ay] = 1;
    for (y = Ay+1; y <= By; y++) {
      ways[Ax][y] = !blockS[Ax][y]; 
    }

    for (x = Ax+1; x <= Bx; x++) {
      for (y = Ay; y <= By; y++) {
	ways[x][y] = (blockW[x][y]) ? 0 : ways[x-1][y];
	if (y > Ay && !blockS[x][y]) {
	  ways[x][y] += ways[x][y-1];
	}
      }
    }

    printf("%lld\n", ways[Bx][By]);
  }

  return 0;
}


Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh
Contact:

Re: 926 - Walking Around Wisely

Post by Jan » Thu Jun 05, 2008 11:13 pm

The identifier for 'unsigned long long' is '%llu'. Hope it helps.
Ami ekhono shopno dekhi...
HomePage

howardcheng
Learning poster
Posts: 71
Joined: Thu Aug 21, 2003 1:56 am

Re: 926 - Walking Around Wisely

Post by howardcheng » Thu Jun 05, 2008 11:26 pm

Yes, of course. Too long since I have done C programming :(

howardcheng
Learning poster
Posts: 71
Joined: Thu Aug 21, 2003 1:56 am

Re: 926 - Walking Around Wisely

Post by howardcheng » Fri Jun 06, 2008 9:46 am

Still WA.

joy
New poster
Posts: 48
Joined: Wed Oct 18, 2006 1:00 pm
Location: Dhaka, Bangladesh
Contact:

Re: 926 - Walking Around Wisely

Post by joy » Wed Jul 09, 2008 4:20 am

try this:

Code: Select all

1
3
1 1
3 3
2
2 3 S
3 2 W
form kisui na ... class tai asol....
iF U hv d class u get the form....

howardcheng
Learning poster
Posts: 71
Joined: Thu Aug 21, 2003 1:56 am

Re: 926 - Walking Around Wisely

Post by howardcheng » Wed Jul 09, 2008 5:39 pm

My program gives "2" for the above input, which is correct as far as I can tell.

Shafaet_du
Experienced poster
Posts: 147
Joined: Mon Jun 07, 2010 11:43 am
Location: University Of Dhaka,Bangladesh
Contact:

Re: 926 - Walking Around Wisely

Post by Shafaet_du » Fri Aug 26, 2011 8:17 am

Jan vai's i/o giving me segment fault in my ac code.

Post Reply

Return to “Volume 9 (900-999)”