11850 - Alaska

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

Moderator: Board moderators

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

Re: 11850-Alaska

Post by brianfry713 »

Input:

Code: Select all

8
400
1200
800
0
600
1400
200
1000
0
AC output:

Code: Select all

POSSIBLE
Check input and AC output for thousands of problems on uDebug!
uvasarker
Learning poster
Posts: 96
Joined: Tue Jul 19, 2011 12:19 pm
Location: Dhaka, Bangladesh
Contact:

Re: 11850-Alaska

Post by uvasarker »

Hi
Boss,
I updated more. But
Still WA. Please help me. Here is my code:

Code: Select all

/* Removed */ AC
@li_kuet
New poster
Posts: 44
Joined: Fri May 25, 2012 6:22 pm
Location: Chittagong, Bangladesh

Re: 11850-Alaska

Post by @li_kuet »

Try this Input :

Code: Select all

8
0
200
400
600
800
900
1100
1300
0
Output :

Code: Select all

IMPOSSIBLE
omarking05
New poster
Posts: 3
Joined: Sat Dec 08, 2012 5:16 pm

Re: 11850-Alaska

Post by omarking05 »

hey ..
can anybody tell me please whats wrong with my code ?

Code: Select all

#include <iostream> 
using namespace std; 

int main ()
{
	int n , lo[1430],count=1;
	while(cin>>n&&n!=0)
	{
		count=1;
		for (int i=0;i<n;i++)
		{
			cin>>lo[i];
		}
		for (int j=0;j<n;j++)
		{

				if (lo[j]>lo[j+1])
				{
					if (lo[j]-lo[j+1]<=200)
						count++;
					cout<<count<<endl;
				}
				else if (lo[j]<lo[j+1])
				{
					if (lo[j+1]-lo[j]<=200)
						count++;
				}
		}
		if (count==n) cout<<"POSSIBLE"<<endl;
		else cout<<"IMPOSSIBLE"<<endl;
	}
	return 0;
} 
thanks in advance ..
brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 11850-Alaska

Post by brianfry713 »

Don't print count.
Check input and AC output for thousands of problems on uDebug!
milan_aiub
New poster
Posts: 1
Joined: Sun Jun 24, 2012 1:02 pm

Re: 11850-Alaska

Post by milan_aiub »

8
0
200
400
600
800
900
1100
1300
0
Why the output of this case is "IMPOSSIBLE" ?
brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 11850-Alaska

Post by brianfry713 »

She can't make it from the station at 1300 miles to Delta Junction at 1422 miles and back to the station at 1300 miles.
Check input and AC output for thousands of problems on uDebug!
MNT.95
New poster
Posts: 7
Joined: Thu Jan 23, 2014 5:40 pm

Re: 11850-Alaska

Post by MNT.95 »

I don't get the point of coming back ??
I sort them then I check the difference between them, every test case I run in my program is correct, so why I got WA?
brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 11850-Alaska

Post by brianfry713 »

You can't assume there is a charging station at Delta Junction.
Check input and AC output for thousands of problems on uDebug!
ultima_key
New poster
Posts: 10
Joined: Tue Mar 25, 2014 12:50 pm

Re: 11850-Alaska

Post by ultima_key »

Code: Select all

#include <iostream>
#include <algorithm>
using namespace std;

int main(){
	int s;
	while(cin >> s){
		if(s == 0) break;
		int station[s];
		bool conse = true;
		for(int i = 0; i < s; i++) cin >> station[i];
		sort(station, station+s);
		for(int i = 0; i < s-1; i++){
			if(abs(station[i]-station[i+1]) != 200){
				conse = false;
				break;
			}
		}
		if(conse) cout << "POSSIBLE" << endl;
		else cout << "IMPOSSIBLE" << endl;
	}
}
Why is my code returning a WA verdict? Every input I saw here was correct.
brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 11850-Alaska

Post by brianfry713 »

Input:

Code: Select all

8
1399
1200
1000
800
600
400
200
0
0
AC output: POSSIBLE
Check input and AC output for thousands of problems on uDebug!
uDebug
A great helper
Posts: 475
Joined: Tue Jul 24, 2012 4:23 pm

Re: 11850-Alaska

Post by uDebug »

Replying to follow the thread.
Check input and AC output for over 7,500 problems on uDebug!

Find us on Facebook. Follow us on Twitter.
Shahidul.CSE
Experienced poster
Posts: 148
Joined: Sun Jul 13, 2014 4:32 am
Location: Rangpur, Bangladesh

11850-Alaska

Post by Shahidul.CSE »

Why WA with my code ?

Code: Select all

#include<stdio.h>
int main()
{
    long long int n, i,j, station[1435],temp,flag;
    while(scanf("%lld",&n) && n!=0)
    {
        flag=1;
        for(i=0;i<n;i++)
            scanf("%lld",&station[i]);
        for(i=0;i<n;i++)
          {
            for(j=0;j<n-1;j++)
            if(station[j]<station[j+1])
            {
                temp=station[j];
                station[j]=station[j+1];
                station[j+1]=temp;
            }
          }
            for(i=0;i<n-1;i++)
                {
                    if((station[i]-station[i+1])>200)
                    {
                        flag=0;
                        break;
                    }
                }
                if(flag==0)
                    printf("IMPOSSIBLE\n");
                else if(flag==1)
                    printf("POSSIBLE\n");
    }
    return 0;
}

Md. Shahidul Islam
Dept. of CSE at Begum Rokeya University, Rangpur, Bangladesh
UVa id: http://uhunt.felix-halim.net/id/438420
My facebook account,
Email me: shahidul.cse.brur@gmail.com
lighted
Guru
Posts: 587
Joined: Wed Jun 11, 2014 9:56 pm
Location: Kyrgyzstan, Bishkek

Re: 11850-Alaska

Post by lighted »

The problem description says:
Can Brenda drive her car from Dawson City to Delta Juntion and back?
Try input

Code: Select all

8
1300
1200
1000
800
600
400
200
0
0
Correct output is

Code: Select all

IMPOSSIBLE
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman
Shahidul.CSE
Experienced poster
Posts: 148
Joined: Sun Jul 13, 2014 4:32 am
Location: Rangpur, Bangladesh

Re: 11850-Alaska

Post by Shahidul.CSE »

For above input, how the output be

Code: Select all

IMPOSSIBBLE
please explain it.
Md. Shahidul Islam
Dept. of CSE at Begum Rokeya University, Rangpur, Bangladesh
UVa id: http://uhunt.felix-halim.net/id/438420
My facebook account,
Email me: shahidul.cse.brur@gmail.com
Post Reply

Return to “Volume 118 (11800-11899)”