## Algorithm

Problem Name: beecrowd | 2493

By João Marcos Salvanini Bellini de Moraes, IFSULDEMINAS Brazil

Timelimit: 1

Samu Elmito loves creating peculiar games to challenge his friends. This time, he made a game called "Jogo do Operador" (Operation Game), in which he creates basic expresssions and each player must choose an expression and fill the gap with the correct operation to validate it. The players may choose 1 out of 3 operations: addition, subtraction and multiplication. However, if the player thinks there's no operation among the 3 operations that validates the expression, he can anwser Impossible.

Your task is simple: given the expressions and the players' answer, determine which players won't proceed to the next phase of the game.

## Input

The input consists of an integer T (2 ≤ T ≤ 50) that indicates the number of expression and the number of players. Each test case consists of T expressions like "X Y=Z", indicating that X operation Y (0 ≤ X, Y ≤ 103) is equal to Z (-103Z ≤ 106), followed by T players and his respective answers like "N E R", with N being the player's name (up to 50 characters and no blank spaces), E being the index of the chosen expression (1 ≤ E T) and R the answer (+, -, * or I, indicating Impossible). Read input until EOF.

## Output

For each test case, if every player can proceed, print "You Shall All Pass!"; if no player can proceed, print "None Shall Pass!"; otherwise, print, in lexicographical order and between blank spaces, the name of the players who gave the wrong answer and won't proceed to the next phase.

 Input Sample Output Sample 3 8 4=5 2 5=5 1 3=4 Samuel 2 + Abner 3 + Aline 1 * 2 1 2=-1 0 7=7 Luiz 2 - Absolut 1 + Aline Samuel None Shall Pass!

## Code Examples

### #1 Code Example with C++ Programming

```Code - C++ Programming```

``````
#include "bits/stdc++.h"
#define f(inicio, fim) for(int i = inicio; i  <  fim; i++)
#define ff(inicio, fim) for(int j = inicio; j  <  fim; j++)
#define fff(inicio, fim) for(int k = inicio; k  <  fim; k++)
#define print(vetor) for(auto elem : vetor) cout << elem << " "

using namespace std;

int main() {

ios_base::sync_with_stdio(false);
cin.tie(NULL);

int t;
while(cin >> t){
vector <  vector<int> > vetor(t);
f(0, t){
string tmp, foo;
int aux;
cin >> aux;
vetor[i].push_back(aux);
cin >> tmp;
istringstream ss(tmp);
while(getline(ss, foo, '='))
vetor[i].push_back(atoi(foo.c_str()));
}

set < string> nome;
f(0, t){
string name;
int pos;
char op;
cin >> name >> pos >> op;
--pos;
int prim = vetor[pos][0], seg = vetor[pos][1], ter = vetor[pos][2];

switch (op){
case '+':
if(prim + seg != ter)
nome.insert(name);
break;
case '-':
if(prim - seg != ter)
nome.insert(name);
break;
case '*':
if(prim * seg != ter)
nome.insert(name);
break;
case 'I':
if(prim + seg == ter || prim - seg == ter || prim * seg == ter)
nome.insert(name);
break;
}
}

if(nome.size() == 0)
cout << "You Shall All Pass!\n";
else if(nome.size() == t)
cout << "None Shall Pass!\n";
else{
auto it = nome.begin();
cout << *it;
it = next(it);
while(it != nome.end()){
cout << " " << *it;
it = next(it);
}
cout << "\n";
}
}

return 0;
}

``````
Copy The Code &

Input

cmd
3 8 4=5 2 5=5 1 3=4 Samuel 2 + Abner 3 + Aline 1 * 2 1 2=-1 0 7=7 Luiz 2 - Absolut 1 +

Output

cmd
Aline Samuel None Shall Pass!

### #2 Code Example with Javascript Programming

```Code - Javascript Programming```

``````
var lines = input.split('\n');
const values = input.split("\n");
const operacoes = (loop) => {
const respostas = [];
for (let i = 0; i  <  loop; i++) {
const questoes = values.shift();
const formatacoes = questoes.replace("=", " ").split(" ");
const listaq = formatacoes.map((q) =>
parseInt(q)
);

if (listaq[0] + listaq[1] === listaq[2]) {
respostas.push("+");
} else if (listaq[0] - listaq[1] === listaq[2]) {
respostas.push("-");
} else if (listaq[0] * listaq[1] === listaq[2]) {
respostas.push("*");
} else {
respostas.push("I");
}
}
return respostas;
};

const jogadores = (loop, listAnwser) => {
const errou = [];
for (let i = 0; i  <  loop; i++) {
const [name, question, answer] = values.shift().split(" ");

if (answer !== listAnwser[question - 1]) {
errou.push(name);
}
}

if (errou.length === 0) {
return "You Shall All Pass!";
}

if (errou.length === loop) {
return `None Shall Pass!`;
}

errou.sort();
return errou.join(" ");
};

while (values.length > 0) {
const loop = parseInt(values.shift());

if (isNaN(loop)) {
break;
}

const listQuestionsAnwser = operacoes(loop);
}

``````
Copy The Code &

Input

cmd
3 8 4=5 2 5=5 1 3=4 Samuel 2 + Abner 3 + Aline 1 * 2 1 2=-1 0 7=7 Luiz 2 - Absolut 1 +

Output

cmd
Aline Samuel None Shall Pass!