Moderator: Board moderators

New poster
Posts: 17
Joined: Tue Dec 22, 2009 4:20 pm

I am getting WA. Can anyone give me any hints.

Leonid
Experienced poster
Posts: 146
Joined: Thu Dec 22, 2005 5:50 pm
Contact:

Make sure that the range of the electric car is enough to travel from the Delta Junction to the nearest city with a fuel station and back.

New poster
Posts: 17
Joined: Tue Dec 22, 2009 4:20 pm

Should I consider that her journey begins form 0 and ends at 1422? My algo is something like that: I am taking the input in an array & sort it. Then I am checking difference between index 0&1, 1&2, 2&3.... is<=200. Is it correct??

Leonid
Experienced poster
Posts: 146
Joined: Thu Dec 22, 2005 5:50 pm
Contact:

This is not enough, as according to the problem description you need to go back as well.
Can Brenda drive her car from Dawson City to Delta Juntion and back?

New poster
Posts: 17
Joined: Tue Dec 22, 2009 4:20 pm

Got AC. Thanks Leonid.

Mizanur Rahman(IUK)
New poster
Posts: 12
Joined: Wed Aug 18, 2010 12:07 pm

please send me some critical input

Code: Select all

``````#include<stdio.h>
#include<math.h>
#include<stdlib.h>
int  sort(int a[],int n)
{
int i,j;
for(i=0;i<n-1;i++)
{
for(j=0;j<n-i-1;j++)
if(a[j]>a[j+1])
{
int 	tmp=a[j];a[j]=a[j+1];a[j+1]=tmp;
}
}
return 0;
}
int main()
{
int n,i;
scanf("%d",&n);
while(n)
{
int a[2000],s=0;
//a[0]=1422;
for(i=0;i<n;i++)
scanf("%d",&a[i]);
sort(a,n);
a[n]=1422;
//for(i=0;i<n;i++)
//	printf(" %d ",a[i]);
for(i=1;i<n-1;i++)
{
if(abs(a[i+1]-a[i])>200)
{s=1;break;}
}
if((a[0]-0)>100||(1422-a[n-1])>100)
s=1;
if(s)
printf("IMPOSSIBLE\n");
else   	printf("POSSIBLE\n");
scanf("%d",&n);
}
return 0;
}
``````

New poster
Posts: 17
Joined: Tue Dec 22, 2009 4:20 pm

You need not to check at a[0]. a[0]-0 can be greater than 100. if you have a charging station at 0 and at 150 you can travel. you have to check while returning.

simple simon
New poster
Posts: 2
Joined: Fri Mar 05, 2010 12:12 pm

i am getting wa in this problem.......but it seems easy to me........any suggestion or critical input plz..??

helloneo
Guru
Posts: 516
Joined: Mon Jul 04, 2005 6:30 am
Location: Seoul, Korea

http://acm.uva.es/board/viewtopic.php?f=53&t=50759

And do not make a new one..

naseef_07cuet
Learning poster
Posts: 62
Joined: Sat Nov 21, 2009 10:17 pm

If you have determination, you can do anything you want....

Shafaet_du
Experienced poster
Posts: 147
Joined: Mon Jun 07, 2010 11:43 am
Contact:

You cant return only if you cant reach the nearest station to delta junction while returning.

naseef_07cuet
Learning poster
Posts: 62
Joined: Sat Nov 21, 2009 10:17 pm

I found this problem similar to 11608.
If you have determination, you can do anything you want....

uvasarker
Learning poster
Posts: 96
Joined: Tue Jul 19, 2011 12:19 pm
Contact:

Please give me some critical i/o test cases so that I can get rid of this problem.
Here is my code:

Code: Select all

``````#include <cstdio>

int main()
{
long n;
while(scanf("%ld",&n)==1)
{
if(n==0) break;
long station[10000],I,J,fag=0;

for(I=0 ; I<n ; I++)
{
scanf("%ld",&station[I]);
if(station[I]>1222)
fag=1;
}

if(fag==1)
{
int dis=0;
for(J=0 ; J<n ; J++)
{
dis=station[I+1]-station[I];
if(dis>200 || dis<-200)
{
fag=0;
break;
}
}

if(fag==0)
printf("IMPOSSIBLE\n");
else
printf("POSSIBLE\n");
}
else
printf("IMPOSSIBLE\n");
fag=0;
}
return 0;
}

``````

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Input:

Code: Select all

``````7
600
1400
400
1200
200
1000
0
0``````
Output is:

Code: Select all

``IMPOSSIBLE``
Check input and AC output for thousands of problems on uDebug!

uvasarker
Learning poster
Posts: 96
Joined: Tue Jul 19, 2011 12:19 pm
Contact:

Hi boss,
Here is my code:

Code: Select all

``````#include <cstdio>

int main()
{
long n;
while(scanf("%ld",&n)==1)
{
if(n==0) break;
long station[100000],I,J,fag=1;

for(I=0 ; I<n ; I++)
{
scanf("%ld",&station[I]);
}
int dis=0;
for(J=0 ; J<n ; J++)
{
dis=station[J+1]-station[J];
if(dis>200 || dis<-200)
{
fag=0;
break;
}
}

if(fag==0)
printf("IMPOSSIBLE\n");
else
printf("POSSIBLE\n");
fag=1;
}
return 0;
}

``````