Last active
September 1, 2019 09:08
-
-
Save 08vivek08/bb64baf0ab3e4a363415488612cd4760 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
int main() { | |
int t; | |
cin>>t; | |
while(t--){ | |
int a[3],c[3]; | |
// input | |
for(int i=0;i<3;i++){ | |
cin>>a[i]; | |
} | |
for(int i=0;i<3;i++){ | |
cin>>c[i]; | |
} | |
// Max & min | |
int maxage=0,minage=0; | |
for(int i=1;i<3;i++){ | |
if(a[i]>a[maxage]){ | |
maxage=i; | |
} | |
if(a[i]<a[minage]){ | |
minage=i; | |
} | |
} | |
if(maxage!=minage){ | |
int other=3-maxage-minage; | |
// cout<<maxage<<" "<<minage<<" "<<other<<"\n"; | |
if(a[other]==a[maxage] && c[other]==c[maxage] && c[minage]<c[maxage]){ | |
cout<<"FAIR\n"; | |
} | |
else if(a[other]==a[minage] && c[other]==c[minage] && c[minage]<c[maxage]){ | |
cout<<"FAIR\n"; | |
} | |
else if(a[other]<a[maxage] && a[other]>a[minage] && c[other]<c[maxage] && c[other]>c[minage] && c[minage]<c[maxage]){ | |
cout<<"FAIR\n"; | |
} | |
else{ | |
cout<<"NOT FAIR\n"; | |
} | |
} | |
else{ | |
if(c[0]==c[1] && c[1]==c[2]){ | |
cout<<"FAIR\n"; | |
} | |
else{ | |
cout<<"NOT FAIR\n"; | |
} | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment