I finally solved this problem with your help and it also shows 100[100pts] . Still why does it show up under partially solved in my profile ? Any idea ?
It will update after some timeā¦
#include<bits/stdc++.h>
using namespace std;
int main()
{ long long t,n,x,a,b,p,ps,ma,mi;
cin >> t;
while(tā){
cin >> n;
int w=0;
while(nā){
cin >> x >> a >> b;
if(x==1 || a==b) {w=1; if(w)cout << "YES" << '\n'; p=a; ps=b;}
else if(w==0) {cout << "NO" << '\n'; p=a; ps=b;}
else if(w){
ma=max(a,b);
if(b==ma)mi=a;
else mi=b;
if(p==ps) {cout << "NO" << '\n';}
else if(p>ps){
if(mi>=p) cout << "NO" << '\n';
else if(mi<p && ma>=p) cout << "YES" << '\n';
else cout << "NO" << '\n';
}
else{
if(mi>=ps) cout << "NO" << '\n';
else if(mi<ps && ma>=ps) cout << "YES" << '\n';
else cout << "NO" << '\n';
}
p=a;
ps=b;
}
}
}
}
pls give me any testcase in which it will give wa
@sanket_17 Check out this test case:
1
6
2 1 1
2 1 3
2 2 5
2 4 6
1 8 8
2 8 10
Output Should be
YES
NO
NO
NO
YES
NO
Too many logic (if-else, nested if-else) thatās why Iām not trying to find out your logical defect. You should use this test case and debug your code to see where the bug is.
why i am getting WA for this solution?
https://www.codechef.com/viewsolution/26834508
can anyone help?
/* package codechef; // donāt place package name! */
import java.util.;
import java.lang.;
import java.io.*;
/* Name of the class has to be āMainā only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t-->0){
int n=sc.nextInt();
sc.nextLine();
// String s[]=br.readLine().split("\\r?\\n");
int a[][]=new int[n][3];
for(int i=0;i<n;i++)
{
for(int j=0;j<3;j++)
{
a[i][j]=sc.nextInt();
}
}
int fav=-1,other=-1;
for(int i=0;i<n;i++)
{
if(a[i][0]==1){
System.out.println("YES");
fav=a[i][1];other=a[i][2];}
else{
if(a[i][1]==a[i][2]){
fav=a[i][1];
other=a[i][1];
System.out.println("YES");
}
else if(a[i][1] >= Max(fav,other) &&a[i][2] >= Max(fav,other)){
System.out.println("NO");
}
else if(Min(a[i][1],a[i][2])<=Max(fav,other))
{
System.out.println("YES");
if(fav>other){
fav=Max(a[i][1],a[i][2]);
other=Min(a[i][1],a[i][2]);
}
else {
fav=Min(a[i][1],a[i][2]);
other=Max(a[i][1],a[i][2]);
}
}
else
System.out.println("NO");
}
}
}
}
public static int Min(int a,int b){
if(b<a)
return b;
else return a;
}
public static int Max(int a,int b){
if(b<a)
return a;
else return b;
}
}
got accepted .
The output for the test case shown
1
6
2 0 1
1 3 1
2 3 4
2 5 6
2 8 8
2 9 10
Output:
NO
YES
NO
NO
YES
NO
I think it should be as per question.tell if iam wrong
output:
NO
YES
YES
NO
YES
NO
Your third output is wrong as it should be a NO, because you canāt know if team A stayed at 3 and B got up to 4, or if team A got up to 4 and team B got up to 3.
Your code fails on this case
Test Case
1
1
2 0 0
Expected Output
YES
Your Output
NO
Explanation
We know the score of both the teams since the goals scored by each team is the same. Thus, Team A has scored 0 goals, and Team B has also scored 0 goals.
Hope this helps .