1237 - Expert Enough?

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

Moderator: Board moderators

Post Reply
MarioZarate
New poster
Posts: 1
Joined: Mon Oct 17, 2011 4:17 am

1237 - Expert Enough? Wrong Answer

Post by MarioZarate » Mon Oct 17, 2011 4:24 am

hi,
I have a problem with the 1237, this problem belongs to the Volume XII.
I leave my code so I can help.
Greetings.

Code: Select all

#include <iostream>
#include <vector>
#include <string>
using namespace std;

struct Car
{
	string name;
	int low;
	int high;
	
	Car(string n, int l, int h)
	{
		name = n;
		low = l;
		high = h;
	}
};



int main(int argc, char **argv)
{	
	int N, numDB, numQuery, val, cont;
	cin>>N;
	vector<Car*> database;
	while(N--)
	{				
		cin>>numDB;
		for(int i = 0; i < numDB; i++)
		{
			string n;
			int l, h;
			cin>>n>>l>>h;
			Car* C = new Car(n,l,h);
			database.push_back(C);
		}		
		cin>>numQuery;
		while(numQuery--)
		{
			cont = 0;
			cin>>val;
			int index = 0;
			for(int i = 0; i < numDB; i++)
			{								
				if((val >= database[i]->low) && (val <= database[i]->high))
				{					
					cont++;					
					index = i;
					if(cont > 1) break;
				}
			}
			if(cont == 1) cout<<database[index]->name<<endl;
			else cout<<"UNDETERMINED"<<endl;
		}
		database.clear();		
	}
	return 0;
}

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

Re: 1237 - Expert Enough? Wrong Answer

Post by brianfry713 » Fri Dec 02, 2011 7:44 am

You should separate output for different case by one empty line.
Check input and AC output for thousands of problems on uDebug!

User avatar
uDebug
A great helper
Posts: 475
Joined: Tue Jul 24, 2012 4:23 pm

Re: 1237 - Expert Enough? Wrong Answer

Post by uDebug » Tue Dec 31, 2013 2:48 pm

brianfry713 wrote:You should separate output for different case by one empty line.
Just to further clarify what brianfry713 wrote, here's some input and AC ouput that might help.

Input:

Code: Select all

2 
4 
HONDA 10000 45000 
PEUGEOT 12000 44000 
BMW 30000 75900 
CHEVROLET 7000 37000 
4 
60000 
7500 
5000 
10000
5 
HONDA 10000 45000 
PEUGEOT 12000 44000 
BMW 30000 75900 
CHEVROLET 7000 37000
FIAT 1000 4999 
5 
60000 
7500 
5000 
10000
2000
AC Output:

Code: Select all

BMW
CHEVROLET
UNDETERMINED
UNDETERMINED

BMW
CHEVROLET
UNDETERMINED
UNDETERMINED
FIAT
There should be no newline at the end of the last output.
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

1237 - Expert Enough?

Post by Shahidul.CSE » Wed Jul 16, 2014 9:05 pm

Why having WA with my below code?

code removed after got accepted.
Last edited by Shahidul.CSE on Sat Jul 19, 2014 12:41 pm, edited 1 time in total.
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

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

Re: 1237 - Expert Enough?

Post by brianfry713 » Thu Jul 17, 2014 8:37 pm

Try changing the way you're storing the names, why not use something like:
char maker[9999][21];
Check input and AC output for thousands of problems on uDebug!

lighted
Guru
Posts: 585
Joined: Wed Jun 11, 2014 9:56 pm
Location: Kyrgyzstan, Bishkek

Re: 1237 - Expert Enough?

Post by lighted » Fri Jul 18, 2014 10:53 am

You must increase array limit

Code: Select all

char maker[25],mixed[25000];
It must be

Code: Select all

char maker[25],mixed[200000];
Each case begins with the size of the database D (D < 10000) . The next each of D lines contains M , L and H (0 < L < H < 1000000) which are the name of the maker (contains no whitespace and will never exceeds 20 characters)
array limit at least must be -> 9999 * 20 = 199980
but i prefer this -> 10000 * 20 == 200000

One thing is make sad me.
I saw brute force solution of this problem above and was surprised that he got WA not TLE.
I checked brute force solution myself and got accepted. No need to sort and bsearch. :(

Don't forget to remove your code after getting accepted. 8)
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: 1237 - Expert Enough?

Post by Shahidul.CSE » Fri Jul 18, 2014 6:58 pm

Dear lighted,

Even WA !!
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

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

Re: 1237 - Expert Enough?

Post by brianfry713 » Fri Jul 18, 2014 7:09 pm

brianfry713 wrote:Try changing the way you're storing the names, why not use something like:
char maker[9999][21];
Check input and AC output for thousands of problems on uDebug!

Shahidul.CSE
Experienced poster
Posts: 148
Joined: Sun Jul 13, 2014 4:32 am
Location: Rangpur, Bangladesh

Re: 1237 - Expert Enough?

Post by Shahidul.CSE » Fri Jul 18, 2014 7:16 pm

Ok, thank you....
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: 585
Joined: Wed Jun 11, 2014 9:56 pm
Location: Kyrgyzstan, Bishkek

Re: 1237 - Expert Enough?

Post by lighted » Sat Jul 19, 2014 12:24 pm

I got several times accepted by increasing limit of array mixed to 200000 (5 zeroes).

Code: Select all

char maker[25],mixed[200000];
Maybe you have problems with copy/paste? :)

Try to copy/paste from your post above not from your computer. 8)
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: 1237 - Expert Enough?

Post by Shahidul.CSE » Sat Jul 19, 2014 12:38 pm

Thank you so much.................
Got ac!!

Reason was, I made a little changed with my original code on my pc. Now copping from my post, got AC !!
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

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

Re: 1237 - Expert Enough?

Post by brianfry713 » Mon Oct 13, 2014 9:22 pm

Code: Select all

1
1
HONDA 10000 45000 
2
20000
20000
AC output:

Code: Select all

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

uradura
New poster
Posts: 11
Joined: Thu Jan 01, 2015 10:31 am

Re: 1237 - Expert Enough?

Post by uradura » Tue Jan 06, 2015 7:46 am


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

Re: 1237 - Expert Enough?

Post by brianfry713 » Wed Jan 07, 2015 3:02 am

It looks like you figured it out.
Check input and AC output for thousands of problems on uDebug!

Post Reply

Return to “Volume 12 (1200-1299)”