Hello pro-coders!
I’m some kind of trouble using C++ in Codechef. I was solving SINGTOUR (CodeChef: Practical coding for everyone) 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