Click here to Skip to main content
15,890,579 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
This is my online test, it is talking about verdict in competitive programming. I am asking about how to get multiple outputs with the same "if-else" statement and how to turn the "T" into number of cases, so that if I enter 4 number of cases, it will allow me to give 4 different inputs and having also 4 outputs?

Input
The first row consist of number T (1≤ T ≤ 100) which shows how many are the test cases. For every case, it consist of 6 type of numbers, Wj,Wp,Mj,Mp,Jj,Jp ( 1 ≤ Wj,Wp,Mj,Mp,Jj,Jp ≤ 100) with each shows time limit, process time needed, memory limit, memory used, judge answer, participant answer.

Output
For every test case,"Case #X: Y", where X shows the case number and Y are as following:
1. If the process time are bigger than the time limit, print "TIME LIMIT EXCEEDED / TIMELIMIT".
2. Else if memory used are bigger than memory limit, print "MEMORY LIMIT EXCEEDED".
3. Else if judge answer ≠ participants answer, print "WRONG-ANSWER".
4. Else print "ACCEPTED / CORRECT".

Sample Input:
4
10 5  10 10 1 1
5  10 5  10 0 1
10 5  5  10 1 1
10 10 10 10 1 2

Sample Output:

Case #1: ACCEPTED / CORRECT
Case #2: TIME LIMIT EXCEEDED / TIMELIMIT
Case #3: MEMORY LIMIT EXCEEDED
Case #4: WRONG-ANSWER


What I have tried:

C++
#include <stdio.h>
int main (){
	int T,Wj,Wp,Mj,Mp,Jj,Jp;
	
	scanf ("%d",&T);
	scanf ("%d %d %d %d %d %d",&Wj,&Wp,&Mj,&Mp,&Jj,&Jp);
	
	if 	(Wp > Wj) {
		printf ("TIME LIMIT EXCEEDED / TIMELIMIT");
	}
	else if (Mp > Mj) {
		printf ("MEMORY LIMIT EXCEEDED");
	}
	else if (Jp!=Jj) {
		printf ("WRONG-ANSWER");
	}
	else {
		printf ("ACCEPTED / CORRECT");
	}
	return 0;
}
Posted
Updated 23-Sep-17 20:00pm

1 solution

C++
while(T-- > 0)  // get values of Wp, Wj .. 'T' times
{
	scanf("%d %d .. ", &Wj, &Wp ...); // get values
	// multiple evaluation 
	printf("%s::%s::%s::%s\n", Wp > Wj ? "TIME LIMIT" : " ", <other tests & corresponding output>, !(Wp > Wj || ... || Jp != Jj) ? "CORRECT " : " ");
}

I am not sure I have understood your requirement exactly but have tried to reply as best as I could interpret.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900