Page 1 of 3

11850 - Alaska

Posted: Tue Oct 05, 2010 7:20 pm
by Rashad
I am getting WA. Can anyone give me any hints. :-?

Re: 11850-Alaska

Posted: Wed Oct 06, 2010 1:24 am
by Leonid
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.

Re: 11850-Alaska

Posted: Wed Oct 06, 2010 5:59 pm
by Rashad
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??

Re: 11850-Alaska

Posted: Wed Oct 06, 2010 11:14 pm
by Leonid
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?

Re: 11850-Alaska

Posted: Sat Oct 09, 2010 9:53 am
by Rashad
Got AC. Thanks Leonid. :)

Re: 11850-Alaska

Posted: Mon Nov 01, 2010 5:17 pm
by Mizanur Rahman(IUK)
wrong answer
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;
}

Re: 11850-Alaska

Posted: Tue Nov 02, 2010 3:05 pm
by Rashad
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. :wink:

11850 - Alaska

Posted: Wed Dec 15, 2010 1:55 am
by simple simon
i am getting wa in this problem.......but it seems easy to me........any suggestion or critical input plz..??

Re: 11850 - Alaska

Posted: Wed Dec 15, 2010 4:27 pm
by helloneo
Use the following thread..

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

And do not make a new one..

Re: 11850-Alaska

Posted: Mon Jan 24, 2011 6:43 pm
by naseef_07cuet
I think Rashed got the bug on your code...please follow him.....

Re: 11850-Alaska

Posted: Sun Mar 06, 2011 8:26 am
by Shafaet_du
You cant return only if you cant reach the nearest station to delta junction while returning.

Re: 11850-Alaska

Posted: Wed Mar 09, 2011 1:48 am
by naseef_07cuet
I found this problem similar to 11608.

Re: 11850-Alaska

Posted: Fri Feb 10, 2012 12:47 pm
by uvasarker
Please, Anyone will help me I am getting wrong answer.
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;
}


Re: 11850-Alaska

Posted: Tue Feb 14, 2012 1:46 am
by brianfry713
Input:

Code: Select all

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

Code: Select all

IMPOSSIBLE

Re: 11850-Alaska

Posted: Tue Feb 14, 2012 1:47 pm
by uvasarker
Hi boss,
I am upset still WA. please help me:
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;
}