Are there any limitations to the use of array-ed version of classes in C++?

Hello pro-coders!

I’m some kind of trouble using C++ in Codechef. I was solving SINGTOUR (https://www.codechef.com/ZCOPRAC/problems/SINGTOUR) of ZCO’s Past Year’s Question Papers, but my solution is partially acceptable by the website.

Here’s my solution: http://codechef.com/viewsolution/27021890

#include <iostream>
using namespace std;

class singers {
	public:
		long long upperbound;
		long long lowerbound;
		long long points;
		singers()
		{
			points=0;
		}
};

void compete(singers &a, singers &b)
{
	if((a.lowerbound == b.lowerbound)||(a.upperbound == b.upperbound))
	{
		a.points++;
		b.points++;
	} else
	if((a.lowerbound<b.lowerbound)&&(a.upperbound == b.upperbound))
	{
		a.points +=2;
	} else 
	if((b.lowerbound<a.lowerbound)&&(a.upperbound == b.upperbound))
	{
		b.points+=2;
	} else 
	if((a.lowerbound == b.lowerbound)&&(a.upperbound>b.upperbound))
	{
		a.points+=2;
	} else 
	if((a.lowerbound ==b.lowerbound)&&(b.upperbound>a.upperbound))
	{
		b.points+=2;
	} else 
	if((a.lowerbound<b.lowerbound)&&(a.upperbound>b.upperbound))
	{
		a.points+=2;
	}else 
	if((b.lowerbound<a.lowerbound)&&(b.upperbound)>(a.upperbound))
	{
		b.points+=2;
	} else {
		a.points++;
		b.points++;
	}
}

int main()
{
	long long n;
	int T;
	cin>>T;
	
	for(int i=0; i<T; i++)
	{
		cin>>n;
		
		singers players[n+1][T];
		
		for(long long j=0; j<n; j++)
		{
			cin>>players[j][i].lowerbound>>players[j][i].upperbound;
		}
		
		for(long long k=0; k<n; k++)
		{
			for(long long l=k; l<n; l++)
			{
				if(k != l)
				{
					compete(players[k][i], players[l][i]);
				}
			}
		}
		
		for(long long j=0; j<n; j++)
		{
			cout<<players[j][i].points<<' ';
		}
		cout<<endl;
	}
	return 0;
}

Clearly, I don’t see any such issue with the code that it is unable to complete subtask 2 and subtask 3. I suspect that the code chef is unable to create large array sizes, so any help to solve my issue is appreciated.

Thanks :slight_smile:

I suspect something is wrong with your approach.
You may take a look at this thread of discussion. @the_extractor has explained it.
Btw, I found it by simply searching SINGTOUR in this website itself.
You too should check out the search feature. It’s LITTT!!! :slightly_smiling_face:

1 Like

Phat rha hai mera bhai, exam ka jaada time ni bacha hai