STL allowed?

Write here if you have problems with your C++ source code

Moderator: Board moderators

Post Reply
u2001137
New poster
Posts: 2
Joined: Fri Feb 24, 2006 9:22 pm

STL allowed?

Post by u2001137 » Fri Feb 24, 2006 9:30 pm

Is STL allowed for C++ submissions of ACM Problems?
(Sorry guys for this question, I have just registered so have very liitle idea about the detailed rules.)

My following code, which compiles well on DevC++, MSVC++6.0 and Comeau Online is rejected by the online judge on the account of "Compile Error". Any help please ....

Code: Select all

#include <iostream>
#include <vector>
#include <string>
#include <limits>
#include <fstream>
#include <iterator>

using namespace std;
const int numCount = 9;

vector<int> ProcessInput();
void DefineOrder(const vector<int>& binConf);



vector<int> ProcessInput()
{
	vector<int> ret;
	while(true)
	{
		int num;
		cin >>  num;
		if(!cin.good()) return ret;
		ret.push_back(num);
		if(ret.size() ==  numCount)
		return ret;
	}



}

	
void DefineOrder(const vector<int>& binConf)
{

	const int BOTTLECONF=6;
	string BottleOrder[BOTTLECONF] = { "BCG","BGC","CBG","CGB","GBC","GCB" };
	int binNB[] = { binConf[1] + binConf[2], binConf[4] + binConf[5], binConf[7] + binConf[8] } ;
	int binNG[] = { binConf[0] + binConf[2], binConf[3] + binConf[5], binConf[6] + binConf[8] } ;
	int binNC[] = { binConf[0] + binConf[1], binConf[3] + binConf[4], binConf[6] + binConf[7] } ;


	vector<int> binCalc;

	int minSum = numeric_limits<int>::max();
	int choice = -1;
	
	for(int i=0; i < BOTTLECONF; ++i)
	{	
		int sum = 0;
		for(int j = 0; j < 3; j++)
		{
			switch(BottleOrder[i][j])
			{
			case 'B':
				sum += binNB[j];
				break;
			case 'C':
				sum += binNC[j];
				break;
			case 'G':
				sum += binNG[j];
				break;
			}
		}
		if(sum < minSum)
		{
			minSum = sum;
			choice = i;
		}

				
	}

	cout << BottleOrder[choice] << " " << minSum << endl;
	
}



int main()
{
	
	vector<int> ret;
	while(true)
	{
		ret.clear();
		ret = ProcessInput();
		if(ret.size() != numCount)
			exit(0);
		DefineOrder(ret);
	}

}

User avatar
Krzysztof Duleba
Guru
Posts: 584
Joined: Thu Jun 19, 2003 3:48 am
Location: Sanok, Poland
Contact:

Post by Krzysztof Duleba » Fri Feb 24, 2006 9:58 pm

g++ 2.95 doesn't support <limits>.
For millions of years, mankind lived just like the animals. Then something happened which unleashed the power of our imagination. We learned to talk and we learned to listen...

u2001137
New poster
Posts: 2
Joined: Fri Feb 24, 2006 9:22 pm

Post by u2001137 » Fri Feb 24, 2006 10:29 pm

Krzysztof Duleba wrote:g++ 2.95 doesn't support <limits>.
Thanks a lot (say INT_MAX thanks) :-) This was precisely the problem.

As an aside, are there any plans of upgrading to one of the newer stable version of g++ (like 3.4.2 or later)?

User avatar
Krzysztof Duleba
Guru
Posts: 584
Joined: Thu Jun 19, 2003 3:48 am
Location: Sanok, Poland
Contact:

Post by Krzysztof Duleba » Sat Feb 25, 2006 12:24 am

u2001137 wrote:As an aside, are there any plans of upgrading to one of the newer stable version of g++?
No that I'm aware of.

I keep gcc 2.95 on all my machines just to compete here :-)
For millions of years, mankind lived just like the animals. Then something happened which unleashed the power of our imagination. We learned to talk and we learned to listen...

Post Reply

Return to “C++”