Chef and Football - WATCHFB

Can you tell what’s wrong with my code
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
using namespace std;

int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin>>t;
while(t–){
int n;
cin>>n;
int val = 0;
while(n–){
int a,b,c;
cin>>a>>b>>c;
if(a==1){
cout<<“YES”<<endl;
val = b;
}
else{
int k = min(b,c);
int k1 = max(b,c);
if(b==c){
cout<<“YES”<<endl;
val = b;
}
else{
if(k<val){
cout<<“YES”<<endl;
val = k1;
}
else{
cout<<“NO”<<endl;
}
}
}
}
}
return 0;
}

You algorithm just tracking the maximum score, so assigningval = b is wrong. You should assign maximum score to the val [val = max(b, c)] like you do in your code:

Check out this test case:

1
6
1 1 3
2 2 3
2 3 5
2 5 6
2 8 8
2 9 10
Output should be :
YES
YES
NO
NO
YES
NO

Thanks bro, but the problem was I was not tracking the score of other team,
this is the correct code

#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    int t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        int val = 0;
        int val1 = 0;
        while(n--){
            int a,b,c;
            cin>>a>>b>>c;
            if(a==1){
                cout<<"YES"<<endl;
                val = b;
                val1 = c;
            }
            else{
                int k = min(b,c);
                int k1 = max(b,c);
                if(b==c){
                    cout<<"YES"<<endl;
                    val = b;
                    val1 = b;
                }
                else{
                    if(k<val){
                        cout<<"YES"<<endl;
                        val = k1;
                        val1 = k;
                    }
                    else{
                        if(k<val1){
                            cout<<"YES"<<endl;
                            val = k;
                            val1 = k1;
                        }
                        else{
                           cout<<"NO"<<endl;   
                        }
                    }
                }
            }
        }
    }
	return 0;
}

This test case helped

1
4
2 0 1
1 3 1
1 4 7
2 5 8

for the case of

2 5 8

If I do not track the score of other team, the result will be NO, but if we track the score of other team, we can say that score of other team is 7 from previous test case 1 4 7 , thus 8 cannot be the score of other team, so the score of fav team is 5, thus answer is YES.
Thanks.

@mohitmm Sounds good. It would be great if you track both team scores, But if you don’t want to track both scores, then you can do it using tracking maximum score,

Here is a AC solution which track only maximum score.