Member 13425895 Ответов: 1

Несколько if else C++


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


Что я уже пробовал:

#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;
}

1 Ответов

Рейтинг:
2

RAMASWAMY EKAMBARAM

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 " : " ");
}

Я не уверен, что точно понял ваше требование, но постарался ответить как можно лучше.