Test Cases

thanks . that worked !

1 Like

getting wa in 5th test case

#include <stdio.h>

int main() {
int n, cl, ml, d, prob1=0, prob2=0, prob3=0, temp1, temp2,v=0, temp3;
scanf(“%d%d%d”, &n, &cl, &ml);
temp1 = cl+1;
temp2 = ml+1;
temp3 = n;
while(n–){
scanf(“%d%d%d”, &d, &cl, &ml);
if(cl >= temp1) prob1++;
else if(ml >= temp2) prob2++;
else if(d != 0) prob3++;
else v++;
}
if(prob1 > 0) printf(“CLE\n”);
else if(prob2 > 0) printf(“MLE\n”);
else if(prob3 > 0) printf(“WA\n”);
else if(v == temp3) printf(“AC\n”);
return 0;
}

Can you please format your code correctly and explain to me how is it working? I can’t understand what you are doing.

However, even though I have not checked your code thoroughly, I can still guess the error to some extent. I think you are checking for each test case. but once you find and error (CLE, MLE or WA) you don’t require to check other test cases. Just skip them and write down the answer.

I am geeting WA in 7th test case… My code:-

#include <iostream>

using namespace std;

enum Verdicts { AC, WA, CLE, MLE };

Verdicts getVerdict(int* temp, int* limits) {
	if(temp[0] == 0) {
		if(temp[1] <= limits[0]) {
			if(temp[2] <= limits[1])
				return Verdicts::AC;

			return Verdicts::MLE;
		}

		return Verdicts::CLE;
	}

	return Verdicts::WA;
}

int main(void) {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int T, CL, ML;

	const char* results[] = { "AC", "WA", "CLE", "MLE" };

	cin >> T >> CL >> ML;

	int limits[] = { CL, ML };
	int temp[3];

	bool proceed = true;

	Verdicts result;

	while(T--) {
		cin >> temp[0] >> temp[1] >> temp[2];

		if(proceed)
			result = getVerdict(temp, limits);

		if(result != Verdicts::AC)
			proceed = false;
	}

	cout << results[result] << endl;

	return 0;
}

what is wrong with my code???

You have to print the 1st verdict you get if its not AC.
Your problem is that you are most likely printing the last one.

I’m getting wrong ans in case 6

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

int diff[10];
int cpu[10];
int mem[10];
int main()
{
    int n,cpul,meml,i;
    scanf("%d%d%d",&n,&cpul,&meml);
    for(i=0;i<n;i++)
       scanf("%d%d%d",&diff[i],&cpu[i],&mem[i]);
    for(i=0;i<n;i++)
    {
        if(diff[i]!=0)
        {
            printf("WA\n");
            return 0;
        }
        if(cpu[i]>cpul)
        {
            printf("CLE\n");
            return 0;
        }
        if(mem[i]>meml)
        {
            printf("MLE\n");
            return 0;
        }
    }
    printf("AC\n");
    return 0;
}

What is the problem with the following code?
n,cpul,ml=map(int,input().split())
dic={}
an=0
for i in range(n):
a=list(map(int,input().split()))
if a[0]!=0:
an+=1
dic[an]=‘WA’
elif a[1]>cpul:
an+=1
dic[an]=‘CLE’
elif a[2]>ml:
an+=1
dic[an]=‘MLE’
if dic=={}:
print(‘AC’)
else:
print(dic.get(1))

 Scanner sc=new Scanner(System.in);
        int N=sc.nextInt();
        int CPUL=sc.nextInt();
        int MEML=sc.nextInt();
        int wa[]=new int[N];
        int cpu[]=new int[N];
        int mle[]=new int[N];
        for (int i = 0; i <N; i++) {
            wa[i]=sc.nextInt();
            cpu[i]=sc.nextInt();
            mle[i]=sc.nextInt();
        }
        for (int i = 0; i <N; i++) {
            if((wa[i]==0)&&(cpu[i]<=CPUL)&&(mle[i]<=MEML)){
                 continue;
            }else if((wa[i]!=0)||(cpu[i]>CPUL)||(mle[i]>MEML)){
                if(wa[i]!=0){
                    System.out.println("WA");
                    System.exit(0);
                }else if(cpu[i]>CPUL){
                    System.out.println("CLE");
                     System.exit(0);
                }else if(mle[i]>MEML){
                    System.out.println("MLE");
                     System.exit(0);
                }
            }
        }
        System.out.println("AC");

whtas the problem in my code . wa in 6 case

tell me the problem of my code .

 Scanner sc=new Scanner(System.in);
    int N=sc.nextInt();
    int CPUL=sc.nextInt();
    int MEML=sc.nextInt();
    int wa[]=new int[N];
    int cpu[]=new int[N];
    int mle[]=new int[N];
   if((N>0)&&(N<10)&&(CPUL>0)&&(CPUL<16)&&(MEML>0)&&(MEML<512)){
   for (int i = 0; i <N; i++) {
        wa[i]=sc.nextInt();
        cpu[i]=sc.nextInt();
        mle[i]=sc.nextInt();
    }
    for (int i = 0; i <N; i++) {
        if((wa[i]==0)&&(cpu[i]<=CPUL)&&(mle[i]<=MEML)){
             continue;
        }else{
            if(wa[i]!=0){
                System.out.println("WA");
                System.exit(0);
            }else if(cpu[i]>CPUL){
                System.out.println("CLE");
                 System.exit(0);
            }else {
                System.out.println("MLE");
                 System.exit(0);
            }
        }
    }
    System.out.println("AC");
   }

can u tell me the problem in my code

My code shows correct results when I run on my compiler. But, I don’t know why it is getting a runtime error.
Can anyone tell me why? Or, which part of the code should I correct?

#include <bits/stdc++.h>

using namespace std;

int main(){
int N, CPUL, MMEL;
cin>>N>>CPUL>>MMEL;
int A[N], B[N], C[N];
for (int i = 0; i < N; i++){
cin>>A[i]>>B[i]>>C[i];
}
for (int i = 0; i < N; i++){
if (B[i] > CPUL){
cout<<“CLE”;
return 1;
}
else if (C[i] > MMEL){
cout<<“MLE”;
return 1;
}
else if (A[i] != 0){
cout<<“WA”;
return 1;
}
}
cout<<“AC”;
return 0;

}

Can you tell me why my code is getting a runtime error?

#include <bits/stdc++.h>

using namespace std;

int main(){
int N, CPUL, MMEL;
cin>>N>>CPUL>>MMEL;
int A[N], B[N], C[N];
for (int i = 0; i < N; i++){
cin>>A[i]>>B[i]>>C[i];
}
for (int i = 0; i < N; i++){
if (B[i] > CPUL){
cout<<“CLE”;
return 1;
}
else if (C[i] > MMEL){
cout<<“MLE”;
return 1;
}
else if (A[i] != 0){
cout<<“WA”;
return 1;
}
}
cout<<“AC”;
return 0;

}

My problem got AC,but i have a question ! why break is working here ,i mean i used break in my for loop and thats why after getting the first WA,CLE or MLE it breaks without taking the whole input ,i thougt it wont work,

#include <stdio.h>
int main()
{
    int test,i,cpu[50],mem[50],diff[50],cpcount,diffcount,memcount,c,m;
    scanf("%d",&test);
    scanf("%d %d",&c,&m);
    for(i=0;i<test;i++)
    {
        scanf("%d %d %d",&diff[i],&cpu[i],&mem[i]);

    }
    for(i=0;i<test;i++)
    {
        if(diff[i]!=0)
        {
          printf("WA");
          diffcount=1;
          break;
        }
        if(cpu[i]>c)
        {
            printf("CLE");
            cpcount=1;
            break;
        }
        if(mem[i]>m)
        {
            printf("MLE");
            memcount=1;
            break;
        }
    }
    if(cpcount!=1&&memcount!=1&&diffcount!=1)
    {
        printf("AC");
    }
    return 0;
}

WHAT IS THE PROBLEM IN THIS CODE?WORKS FINE FOR FIRST TEST CASE

a,b,c=map(int,input().split())
d=0
for i in range(a):
	x,y,z=map(int,input().split())
	if x>0:print("WA");break
	elif y>b:print("CLE");break
	elif z>c:print("MLE");break
	else :d+=1
if d==a:print("AC")

Why WA in case 6?

1 Like

You may want to re-read the problem statement. Some verdicts have higher precedence than others.

Thanks… I understood…

how many line of input should we take. I am really confuse.


On the example-1 has 4 test.

On the example-2 also has 4 test.

But Samples has 5 test
and on the uDebug has 5,6,3 test.
so I am confuse. how do I know many input user will give me! :thinking:
please I need your help.

1 Like

You will have to read the input until EOF.

In Python, you can do this by looping over sys.stdin. See the 5th way of taking input in this tutorial: 5 Ways of Taking Input in Python | Toph Tutorials


why it MLE.