# EID2 - Editorial

#include<bits/stdc++.h>
using namespace std;

#define floop(a,b) for(int i=a;i<b;i++)
#define floops(a,b) for(int j=a;j<b;j++)
#define ifloop(a,b) for(vector::iterator it1=a;it1!=b;it1++)
#define tc() int t; cin>>t; while(t–)
#define ll long long
#define ull unsigned long long

int main(){
tc(){
float A[3];
float C[3];
ll count=0;

``````    floop(0,3)
cin>>A[i];
floop(0,3)
cin>>C[i];

float Csum=0;
float Asum=0;
floop(0,3){
Csum=Csum+C[i];
Asum=Asum+A[i];
}
Csum=Csum/3.0;
Asum=Asum/3.0;

floop(0,3){
A[i]=A[i]-Asum;
C[i]=C[i]-Csum;
}

floop(0,3){
if((A[i]<0 && C[i]<0)||(C[i]>0 && A[i]>0)||(C[i]==0 && A[i]==0))
count++;
}

if(count==3){
cout<<"FAIR"<<endl;
}
else
cout<<"NOT FAIR"<<endl;
}
}``````

First time i used codechef and participated in this contest. Here is my code

#include <stdio.h>

int main(void)
{
int no_of_test,a1,a2,a3,c1,c2,c3;
scanf("%d\n",&no_of_test);

``````while(no_of_test--)
{
scanf("%d %d %d %d %d %d\n",&a1,&a2,&a3,&c1,&c2,&c3);

if((a1==a2)&&(a1==a3)&&(c1==c2)&&(c1==c3))
{
printf("FAIR\n");
}

else if(((a1>a2)&&(a1>a3)&&(c1>c2)&&(c1>c3)) || ((a1==a3)&&(c1==c3)))
{
if(((a2>a3)&&(c2>c3))||((a2==a3)&&(c2==c3)))
{
printf("FAIR\n");
}
else if((a3>a2)&&(c3>c2))
{
printf("FAIR\n");
}
else
{
printf("NOT FAIR\n");
}
}
else if(((a2>a1)&&(a2>a3)&&(c2>c1)&&(c2>c3)) || ((a1==a2)&&(c1==c2)))
{
if(((a1>a3)&&(c1>c3))||((a1==a3)&&(c1==c3)))
{
printf("FAIR\n");
}
else if((a3>a1)&&(c3>c1))
{
printf("FAIR\n");
}
else
{
printf("NOT FAIR\n");
}
}
else if(((a3>a1)&&(a3>a2)&&(c3>c1)&&(c3>c2)) || ((a2==a3)&&(c2==c3)))
{
if(((a1>a2)&&(c1>c2))||((a1==a2)&&(c1==c2)))
{
printf("FAIR\n");
}
else if((a2>a1)&&(c2>c1))
{
printf("FAIR\n");
}
else
{
printf("NOT FAIR\n");
}
}
else
{
printf("NOT FAIR\n");
}
}
``````

}

okk thanks,there was a slight mistake due to which i got wa,
now it is ac.

can you tell me why this code is not working???
#include <stdio.h>

int main(void) {
int a[3],c[3],t,i,j,count;
scanf("%d",&t);
while(t–)
{ count=1;
for(i=0;i<3;i++)
scanf("%d",&a[i]);
for(i=0;i<3;i++)
scanf("%d",&c[i]);
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
if((a[i]>a[j] && c[i]<c[j])||(a[i]<a[j]&&c[i]>c[j]))
{count=0;break;}
if(a[i]==a[j] && c[i]!=c[j])
{count=0;break;}
}

``````      }
if(count==0)
printf("NOT FAIR\n");
else
printf("FAIR\n");

}
return 0;
``````

}

Why my code is showing such an error? I am unable to understand the issue!! Please help!

Here is my code:

``````def check_fair(l):
if len(set(l[:3])) == len(set(l[3:])):
for i in range(3):
if l[:3].index(min(l[:3])) == l[3:].index(min(l[3:])):
l[:3].pop(l[:3].index(min(l[:3])))
l[3:].pop(l[3:].index(min(l[3:])))
else:
return "NOT FAIR"
return "FAIR"
else:
return "NOT FAIR"

check = list()
for i in range(int(input())):
l = list(map(int, input().split()))
check.append(check_fair(l))
print(*check, sep="\n")``````

When i am running below code in dev c++ ,i am gettting correct answer.but on submitting it is showing wrong answer.can anyone tell me whats wrong in my code?
#include <stdio.h>
int max(int q[])
{
int max=0,i;

``````for(i=0;i<3;i++)
{
if(q[i]>=max)
max=q[i];
}
return max;
``````

}
int min(int r[])
{
int min=101,i;
for(i=0;i<3;i++)
{
if(r[i]<min)
min=r[i];
}
return min;

}
int main()
{
int t;
scanf("%d",&t);
while(t–)
{
int a[3],c[3];
int i,flag=0,minpos=0,maxpos=0;
for(i=0;i<3;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<3;i++)
{
scanf("%d",&c[i]);
}
if((a[0]==a[1])&&(a[0]==a[2]))
{
if((c[0]==c[1])&&(c[0]==c[2]))
{
flag=1;
}
}
for(i=0;i<3;i++)
{
if(a[i]==max(a))
maxpos=i;
if(a[i]==min(a))
minpos=i;
}
flag=1;
if(flag==1)
printf(“FAIR\n”);
else
printf(“NOT FAIR\n”);
}
}

``````1
17 17 8 63 17 11
``````

PSA - if you’re going to post your code and ask for help, please ensure that it is formatted correctly - use the “Preformatted text” (`</>`), or paste a link to your solution!

‘’’
Created on 31-Aug-2019

@author: Arijeet Mukherjee
‘’’
print("Please enter the number of tries you want to test between 1 to 1000 :\n ")
n=int(input("Enter now : "))
while(n<1 or n >1000):
print(“pls enter tries bw 1 and 1000 \n”)
n=int(input(“Enter now :”))
print(n)
lis=[]
def eid(lis):
if(lis[0]==lis[1]==lis[2]):
if(lis[3]==lis[4]==lis[5]):
print(“FAIR”)
else:
print(“NOT FAIR”)

``````if(lis[0]==lis[1]<lis[2]):
if(lis[3]==lis[4]<lis[5]):
print("FAIR")
else:
print("NOT FAIR")

if(lis[0]==lis[1]>lis[2]):
if(lis[3]==lis[4]>lis[5]):
print("FAIR")
else:
print("NOT FAIR")

if(lis[0]==lis[2]<lis[1]):
if(lis[3]==lis[5]<lis[4]):
print("FAIR")
else:
print("NOT FAIR")

if(lis[0]==lis[2]>lis[1]):
if(lis[3]==lis[5]>lis[4]):
print("FAIR")
else:
print("NOT FAIR")
if(lis[1]==lis[2]<lis[0]):
if(lis[4]==lis[5]<lis[3]):
print("FAIR")
else:
print("NOT FAIR")
if(lis[1]==lis[2]>lis[0]):
if(lis[4]==lis[5]>lis[3]):
print("FAIR")
else:
print("NOT FAIR")

if(lis[0]<lis[1]<lis[2]):
if(lis[3]<lis[4]<lis[5]):
print("FAIR")
else:
print("NOT FAIR")
if(lis[0]<lis[2]<lis[1]):
if(lis[3]<lis[5]<lis[4]):
print("FAIR")
else:
print("NOT FAIR")
if(lis[0]>lis[1]>lis[2]):
if(lis[3]>lis[4]>lis[5]):
print("FAIR")
else:
print("NOT FAIR")
if(lis[0]>lis[2]>lis[1]):
if(lis[3]>lis[5]>lis[4]):
print("FAIR")
else:
print("NOT FAIR")

if(lis[1]<lis[0]<lis[2]):
if(lis[4]<lis[3]<lis[5]):
print("FAIR")
else:
print("NOT FAIR")
if(lis[1]<lis[2]<lis[0]):
if(lis[4]<lis[5]<lis[3]):
print("FAIR")
else:
print("NOT FAIR")
if(lis[1]>lis[0]>lis[2]):
if(lis[4]>lis[3]>lis[5]):
print("FAIR")
else:
print("NOT FAIR")
if(lis[1]>lis[2]>lis[0]):
if(lis[4]>lis[5]>lis[3]):
print("FAIR")
else:
print("NOT FAIR")

if(lis[2]<lis[0]<lis[1]):
if(lis[5]<lis[3]<lis[4]):
print("FAIR")
else:
print("NOT FAIR")
if(lis[2]<lis[1]<lis[0]):
if(lis[5]<lis[4]<lis[3]):
print("FAIR")
else:
print("NOT FAIR")
if(lis[2]>lis[0]>lis[1]):
if(lis[5]>lis[3]>lis[4]):
print("FAIR")
else:
print("NOT FAIR")
if(lis[2]>lis[1]>lis[0]):
if(lis[5]>lis[4]>lis[3]):
print("FAIR")
else:
print("NOT FAIR")
``````

i=0
while (i<n):
print(“Enter age in between 1 and 17 only”)
age1=int(input(“Enter the age of first child :”))
age2=int(input(“Enter the age of second child :”))
age3=int(input(“Enter the age of third child :”))
while(age1<1 or age1 >17):
print(“Enter age of 1st child age between 1 and 17 only : \n”)
age1=int(input(“Enter the age of first child :”))
while(age2<1 or age2 >17):
print(“Enter age of 2nd child age between 1 and 17 only : \n”)
age1=int(input(“Enter the age of second child :”))
while(age3<1 or age3>17):
print(“Enter age of 3rd child age between 1 and 17 only : \n”)
age1=int(input(“Enter the age of third child :”))
print(“Enter the amount in between 1 and 100 only \n”)
mon1=int(input(“Enter the amount of money for first child”))
while(mon1<1 or mon1>100):
print(“Enter money in bw 1 and 100 pls : \n”)
mon1=int(input(“Enter the money of child first :”))
mon2=int(input(“Enter the amount of money for second child”))
while(mon2<1 or mon2>100):
print(“Enter money in bw 1 and 100 pls : \n”)
mon2=int(input(“Enter the money of second child :”))
mon3=int(input(“Enter the amount of money for third child”))
while(mon3<1 or mon3>100):
print(“Enter money in bw 1 and 100 pls : \n”)
mon3=int(input(“Enter the money of third child :”))
lis.append(age1)
lis.append(age2)
lis.append(age3)
lis.append(mon1)
lis.append(mon2)
lis.append(mon3)
print(lis)
eid(lis)
i=i+1

1 Like

Why my code is not being accepted !!!
Does anyone find here any logical issues or any other??

Here is my code:

``````def check_fair(l):
if len(set(l[:3])) == len(set(l[3:])):
for i in range(3):
if l[:3].index(min(l[:3])) == l[3:].index(min(l[3:])):
l[:3].pop(l[:3].index(min(l[:3])))
l[3:].pop(l[3:].index(min(l[3:])))
else:
return "NOT FAIR"
return "FAIR"
else:
return "NOT FAIR"

check = list()
for i in range(int(input())):
#l.append(list(map(int, input().split())))
l = list(map(int, input().split()))
check.append(check_fair(l))
#print(check_fair(l))
print(*check, sep="\n")``````

if its correct for sample input that doesnt mean your logic is perfect for other hidden testcases too … check for other testcases

Consider e.g.

``````1
1 8 10 36 99 80
``````
1 Like

yeah I understand that, but can you find any other issues with my logic or anything ??
because other are not provided here like Hackerrank !!!

yeah this judge dont provide testcases . you have to check on your own test your answer with accepted python solutions

1 Like

Yeah this one didn’t work thanks !!
You r really helpful man thanks:+1:

1 Like

Python solution IF-ELSE

``````#include<bits/stdc++.h>
using namespace std;

int main(){
int t;
cin>>t;
while(t>0){
vector<int> v(6,0);
cin>>v[0]>>v[1]>>v[2]>>v[3]>>v[4]>>v[5];
vector<pair<int,int>> p;
for(int j=0;j<=2;j++)
p.push_back(make_pair(v[j],v[j+3]));

sort(p.begin(),p.end());
int k=1;
for(k;k<p.size();k++)
{
if(((p[k].first) >= (p[k-1].first)) && ((p[k].second) >= (p[k-1].second))){
if(((p[k].first) == (p[k-1].first)) && ((p[k].second) != (p[k-1].second)))
{
cout<<"NOT FAIR"<<endl;
break;
}
continue;
}
else {
cout<<"NOT FAIR"<<endl;
break;
}
}
if(k==p.size())
cout<<"FAIR"<<endl;
t--;
}
return 0;
}``````
``````1
12 4 6 29 24 29
``````

Now, what’s wrong with this code??
I couldn’t find any test cases not working successfully !!!

``````def eidi(l):
if len(set(l[:3])) == len(set(l[3:])):
F = l[:3]
S = l[3:]
for i in range(2):
if F.index(min(F)) == S.index(min(S)):
F.pop(F.index(min(F)))
S.pop(S.index(min(S)))
continue
else:
return "NOT FAIR"
return "FAIR"
else:
return "NOT FAIR"

check = list()
for i in range(int(input())):
l = list(map(int, input().split()))
check.append(eidi(l))

print(*check, sep="\n")``````