Skip to content

Instantly share code, notes, and snippets.

@08vivek08
Last active September 1, 2019 09:08
Show Gist options
  • Save 08vivek08/bb64baf0ab3e4a363415488612cd4760 to your computer and use it in GitHub Desktop.
Save 08vivek08/bb64baf0ab3e4a363415488612cd4760 to your computer and use it in GitHub Desktop.
#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