My solution of ONCHESS I got the error.
Mate,
Improve formatting or provide solution link.
Please format your code properly. Select whole code and press Ctrl + K to format it.
How are you removing details of players who are paired?
Thatās where ur solution is failing i guess. (May be at other points too, canāt tell because of bad formatting)
PS:Improve formatting, only then others would be able to help
You didnāt check if rating of j is compatible with i. i.e.
mini[i]<=rating[j]&&rating[j]<=maxi[i]
Also the first if condition is not necessary, you donāt need to check constraints of input.
1)Timings must be exactly equal, change that line to if(time[i]==time[j])
2)(israted[i]==āratedā||israted[i]==āunratedā)&&(israted[j]==āratedā||israted[j]==āunratedā)) is always true, you should check whether both are either āratedā or āunratedā
Why are you checking the constraints? The inputs will always satisfy the constraints. Remove unnecessary lines.
Read the question 100 times and then start writing code for it !!!
please anyone help me !!
i have solved this que but it shows wrong answer and i am not able to find any error in my solution⦠i had also solved the que POLY of NOV challenge for 2nd subtask⦠why this happens to meā¦
please give me some tricks or a way to know where i am wrongā¦
code for ONCHESS
https://www.codechef.com/viewsolution/16321625
#include <iostream>
using namespace std;
struct abc{
int r;
int mn;
int mx;
int ch;
};
typedef struct abc s;
int main()
{
int T,n,tmp,i,j;
char str[8];
cin >> T ;
while(T--)
{
cin >> n ;
s a[n];
for(i=0;i<8;i++)
{
str[i]=0;
}
for(i=0;i<n;i++)
{
cin >> a[i].r >> a[i].mn >> a[i].mx >> tmp >> str ;
if(tmp%2)
{
if(tmp%3)
a[i].ch=0;
else
a[i].ch=4;
}
else
{
if(tmp%4)
a[i].ch=8;
else
a[i].ch=12;
}
if(str[0]=='u')
{
a[i].ch += 16;
}
for(j=0;j<8;j++)
{
str[j]=0;
}
cin >> str;
if(str[0]=='r')
{
a[i].ch +=2;
for(j=0;j<i;j++)
{
if(a[j].ch%4==2)
{
if(a[i].r >= a[j].mn && a[i].r <= a[j].mx && a[j].r >= a[i].mn && a[j].r <= a[i].mx )
{
a[j].ch=-500;
a[i].ch=-500;
cout << j+1 << endl ;
break;
}
}
}
if(j!=i)
continue;
}
else
{
a[i].ch+=1;
if(str[0]=='b')
a[i].ch*=(-1);
for(j=0;j<i;j++)
{
if(a[i].ch + a[j].ch == 0)
{
if(a[i].r >= a[j].mn && a[i].r <= a[j].mx && a[j].r >= a[i].mn && a[j].r <= a[i].mx)
{
a[j].ch=-500;
a[i].ch=-500;
cout << j+1 << endl ;
break;
}
}
}
if(j!=i)
continue;
}
cout << "wait" << endl;
}
}
return 0;
}
Reading this Q 100 times is a pain thoughā¦
i had also solved the que POLY of NOV challenge for 2nd subtask.. why this happens to me..
Of what relevance is this line here?
@vijju123 I think heās trying to say that he solved a very hard āpolyā problem(Show off) but why he couldnāt solve this problem!!
You can try looking at this solution. It is almost as same as yours.
He solved it only for 30 points, which was easily available on internet. Whats there to show off lol
Please use a better title for asking questions.
> strong text
***Hey, YOU can go through my codes.It is very simple.
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
int i,j,n,rat[102]={0},min[102]={0},max[102]={0},t[102]={0};
char israt[102][10],col[102][10],b[10]="black",w[10]="white",ran[10]="random";
cin>>n;
for(i=1;i<=n;i++) cin>>rat[i]>>min[i]>>max[i]>>t[i]>>israt[i]>>col[i];
int check[102]={0};
for(i=1;i<=n;i++)
{
int flag=0;
if(i==1) cout<<"wait"<<endl;
else
{
for(j=1;j<i; j++)
{
if( (rat[j] <=max[i]) && (rat[j] >=min[i]) && (rat[i] <=max[j]) && (rat[i] >=min[j]) && (t[i]==t[j]) && (strcmp(israt[i],israt[j])==0) && check[j]==0)
{
if((strcmp(col[i],ran)==0 && strcmp(col[j],ran)==0) || (strcmp(col[j],b)==0 && strcmp(col[i],w)==0 ) || (strcmp(col[j],w)==0 && strcmp(col[i],b)==0))
{
flag=1;
cout<<j<<endl;
check[j]=1;
check[i]=1;
break;
}
else continue;
}
else continue;
}
if(flag==0) cout<<"wait"<<endl;
}
}
}
return 0;
}
Read the question 100 times and the competition over!!
It was on the internet? Dang I missed the chance (ą²„ŁŁŁŁŁŁŁŁŁŁą²„)
@vijju123 , Can u tell me what have u edited in this code ??
I have submitted this code & it worked fine.
I fixed the formatting. It was appearing very clumsy if you recall, no new lines and stuff.
ohhh, thanx