10611 - The Playboy Chimp

All about problems in Volume 106. 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
arsalan_mousavian
Experienced poster
Posts: 111
Joined: Mon Jan 09, 2006 6:19 pm
Location: Tehran, Iran
Contact:

Post by arsalan_mousavian » Tue Sep 26, 2006 10:40 pm

try this input :

Code: Select all

5 1 
5 5 5 5 5 
5
the output should be :

Code: Select all

X X 
Hope it Helps . . .
In being unlucky I have the record.

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

WHY P.E. ?

Post by nymo » Thu Dec 14, 2006 7:11 pm

I think, arsalan_mousavian wished to say:

Code: Select all

5
5 5 5 5 5
1
5
... anyway, I am getting P.E. on this problem, What is the expected format?
I tried:

Code: Select all

		if(!lower)
			printf("%c ", 'X');
		else
			printf("%ld ", lower);
		if(!higher)
			printf("%c", 'X');
		else
			printf("%ld", higher);

... and I 've tried both with printing newline after the last case and without it.
regards,
nymo

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

Re: WHY P.E. ?

Post by helloneo » Thu Dec 14, 2006 7:27 pm

nymo wrote: ... anyway, I am getting P.E. on this problem, What is the expected format?
What I did was pretty much like this..

Code: Select all

	while (qn--) {

		if(!lower)
			printf("%c ", 'X');
		else
			printf("%ld ", lower);
		if(!higher)
			printf("%c", 'X');
		else
			printf("%ld", higher);
		printf("\n");
	}

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

Thanks :)

Post by nymo » Fri Dec 15, 2006 12:26 pm

Thanks helloneo, I get ACC. As far as I recall, I pretty much did the same thing and got P.E. and then I changed to different formats... Don't know what is changed... anyway, ACC now and thanks.
regards,
nymo

turcse143
Learning poster
Posts: 81
Joined: Wed May 09, 2007 9:59 pm
Location: (CSE,DU) Dhaka,Bangladesh

Post by turcse143 » Thu Feb 21, 2008 12:06 pm

Sanjana look it.
this is the sample input:

Code: Select all

4
1 4 5 7
4
4 6 8 10

1
1
1
1

3
1 3 3
2
1
3 

5
5 5 5 5 5
1
5

output:
1 5
5 7
7 X
7 X
X X
X 3
1 X
X X
hope it helps.
''I want to be most laziest person in the world''

User avatar
kbr_iut
Experienced poster
Posts: 103
Joined: Tue Mar 25, 2008 11:00 pm
Location: IUT-OIC, DHAKA, BANGLADESH
Contact:

Re: 10611 - The Playboy..(WA)works well for all input in board.

Post by kbr_iut » Fri May 02, 2008 11:51 pm

code deleted after AC
Last edited by kbr_iut on Wed Sep 10, 2008 9:55 am, edited 1 time in total.
It is tough to become a good programmer.
It is more tough to become a good person.
I am trying both...............................

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

Re: 10611 - The Playboy Chimp

Post by Jan » Sat May 03, 2008 2:12 pm

Why 25003? Read the description again.
Ami ekhono shopno dekhi...
HomePage

User avatar
kbr_iut
Experienced poster
Posts: 103
Joined: Tue Mar 25, 2008 11:00 pm
Location: IUT-OIC, DHAKA, BANGLADESH
Contact:

Re: 10611 - The Playboy Chimp(array size changed but now TLE)

Post by kbr_iut » Sat May 03, 2008 6:43 pm

sorry ,,,,,for array size..
but when i increased array size i got TLE...pliz tell me,is my proceed is right?
I used binary search method to find where start==end...then i evaluate the greatest but smaller than the number and smallest and the greater than the number.
i took consider when there is repeated number.
pliz tell me......
It is tough to become a good programmer.
It is more tough to become a good person.
I am trying both...............................

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

Re: 10611 - The Playboy Chimp

Post by Jan » Sun May 04, 2008 12:56 am

'Binary search' is enough for solving this problem. However, check the boundary cases carefully.
Ami ekhono shopno dekhi...
HomePage

User avatar
kbr_iut
Experienced poster
Posts: 103
Joined: Tue Mar 25, 2008 11:00 pm
Location: IUT-OIC, DHAKA, BANGLADESH
Contact:

Re: 10611 - The Playboy Chimp

Post by kbr_iut » Sun May 04, 2008 8:10 am

thanx via.Now AC...
It is tough to become a good programmer.
It is more tough to become a good person.
I am trying both...............................

fido19
New poster
Posts: 1
Joined: Fri Aug 01, 2008 12:27 am

Re: 10611 - The Playboy Chimp

Post by fido19 » Fri Aug 01, 2008 12:31 am

hi guys i was wondering if this problem is solvable in python language if anyone knows this could they post the code as my code doesent work and i have no idea how to solve it please someone out there who knows it can help me

User avatar
vahid sanei
Learning poster
Posts: 84
Joined: Fri Jan 09, 2009 4:37 pm
Location: IRAN

It`s not Impossible

Post by vahid sanei » Mon Feb 09, 2009 10:33 am

i solved this problem with cin and cout in 0.430 sec
and with scanf and printf in 0.060 sec
how can i reduce time of my algorithm? ( i use Binary search for this pb)
thanks in advance :wink:
Impossible says I`m possible

yeasin_acm_solver
New poster
Posts: 11
Joined: Wed Jun 09, 2010 2:30 pm
Location: University Of Science & Technology Chittagong (USTC) Bangladesh

10611 - The Playboy Chimp- why WA ?

Post by yeasin_acm_solver » Fri Oct 22, 2010 9:54 pm

plz some one help me, a im getting wrong ans ,here is my code :

Code: Select all

/*
	Author : Muhammad Yeasin
	University of Science & Technology Chittagong (USTC)
	CSE- 11th Batch
	Bangladesh	Date:	12:11 AM 10/23/2010		uva id : 10611 The Playboy Chimp
	E-mail: gigabyte_yeasin@yahoo.com
*/
#include<cstdio>
#include<sstream>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<algorithm>
#include<set>
#include<queue>
#include<stack>
#include<list>
#include<iostream>
#include<fstream>
#include<numeric>
#include<string>
#include<vector>
#include<cstring>
#include<map>
#include<iterator>
#define pb push_back
#define file { freopen("input.txt","r",stdin);}

using namespace std;

int binary_search_modify(long int *data,int lb, int ub, int item){
	int beg=0, end=ub;
	int mid=(beg+end)/2;
	while((beg<=end)&&(item!=data[mid])){
		if(item<data[mid])
			end=mid-1;
		else
			beg=mid+1;
	mid=(beg+end)/2;
	if(beg==end)
		break;
	}
if(item>=data[mid])
	return mid;
else if(item<data[mid])
	return mid-1;;
return 0;
}


int main()
{
	long int a[50001]={0};
	
	long int n,it,pos;
	//file
	while(scanf("%ld",&n)==1){
		long int i;
		it=0;
		for(i=0;i<n;i++){
			scanf("%ld",&a[i]);
		}
		long int j,m;
		scanf("%ld",&m);
		for(j=0;j<m;j++){
			scanf("%ld",&it);
			pos=0;
			if(it>a[i-1])
				printf("%ld X\n",a[i-1]);
			else if(it==a[0])
				printf("X %ld\n",a[1]);
			else if(it==a[i-1])
				printf("%ld X\n",a[i-2]);
			else{
			pos=binary_search_modify(a,0,n-1,it);
			if(it==a[pos])
				printf("%ld %ld\n",a[pos-1],a[pos+1]);
			else if((it!=a[pos])&&(it<a[i-1]))
				printf("%ld %ld\n",a[pos],a[pos+1]);
			}
		}
	}
return 0;
}

User avatar
sohel
Guru
Posts: 856
Joined: Thu Jan 30, 2003 5:50 am
Location: New York

Re: 10611 - The Playboy Chimp- why WA ?

Post by sohel » Sat Oct 23, 2010 8:55 am

Use the search option located at the top right corner to find existing discussions.
Don't create a new thread for a problem that already exists! Make your post in an existing thread.

User avatar
shaon_cse_cu08
New poster
Posts: 50
Joined: Tue May 25, 2010 9:10 am
Contact:

Re: 10611 - The Playboy Chimp

Post by shaon_cse_cu08 » Thu Jun 23, 2011 8:56 pm

I have modified my binary search algorithm...that is even if it can't find the data it always return nearest location.... I got it AC in 0.036 s .... Plz be careful using this code...Coz the nearest location can be either smaller or the greater one....

Code: Select all

long b_src(long a[],long n,long x)		//a[] is the array...it can be made global...	
{								//n is the total elements....x is what i m looking for..		
	int ini,end,mid;

	ini=0;
	end=n-1;

	while(ini<=end)
	{
		mid=(ini+end)/2;

		if(x==a[mid])
			return (mid);				
		
		else if(x>a[mid])
			ini=mid+1;
		
		else
			end=mid-1;
	}

return mid;                                     //it always returns something (In case of binary search 'return 0')
}
I'll keep holding on...Until the walls come tumbling down...And freedom is all around ..... :x

Post Reply

Return to “Volume 106 (10600-10699)”