Page 1 of 1

1237 - Expert Enough? Wrong Answer

Posted: Mon Oct 17, 2011 4:24 am
by MarioZarate
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;
}

Re: 1237 - Expert Enough? Wrong Answer

Posted: Fri Dec 02, 2011 7:44 am
by brianfry713
You should separate output for different case by one empty line.

Re: 1237 - Expert Enough? Wrong Answer

Posted: Tue Dec 31, 2013 2:48 pm
by uDebug
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.

1237 - Expert Enough?

Posted: Wed Jul 16, 2014 9:05 pm
by Shahidul.CSE
Why having WA with my below code?

code removed after got accepted.

Re: 1237 - Expert Enough?

Posted: Thu Jul 17, 2014 8:37 pm
by brianfry713
Try changing the way you're storing the names, why not use something like:
char maker[9999][21];

Re: 1237 - Expert Enough?

Posted: Fri Jul 18, 2014 10:53 am
by lighted
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)

Re: 1237 - Expert Enough?

Posted: Fri Jul 18, 2014 6:58 pm
by Shahidul.CSE
Dear lighted,

Even WA !!

Re: 1237 - Expert Enough?

Posted: Fri Jul 18, 2014 7:09 pm
by brianfry713
brianfry713 wrote:Try changing the way you're storing the names, why not use something like:
char maker[9999][21];

Re: 1237 - Expert Enough?

Posted: Fri Jul 18, 2014 7:16 pm
by Shahidul.CSE
Ok, thank you....

Re: 1237 - Expert Enough?

Posted: Sat Jul 19, 2014 12:24 pm
by lighted
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)

Re: 1237 - Expert Enough?

Posted: Sat Jul 19, 2014 12:38 pm
by Shahidul.CSE
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 !!

Re: 1237 - Expert Enough?

Posted: Mon Oct 13, 2014 9:22 pm
by brianfry713

Code: Select all

1
1
HONDA 10000 45000 
2
20000
20000
AC output:

Code: Select all

HONDA
HONDA

Re: 1237 - Expert Enough?

Posted: Tue Jan 06, 2015 7:46 am
by uradura

Re: 1237 - Expert Enough?

Posted: Wed Jan 07, 2015 3:02 am
by brianfry713
It looks like you figured it out.