Skip to content

Instantly share code, notes, and snippets.

@fredbr

fredbr/spock.cpp Secret

Created June 13, 2018 17:35
Show Gist options
  • Save fredbr/68933264950bc5247c74b0c34b4a13bf to your computer and use it in GitHub Desktop.
Save fredbr/68933264950bc5247c74b0c34b4a13bf to your computer and use it in GitHub Desktop.
// solucao de Davi Gabriel
#include <bits/stdc++.h>
using namespace std;
int battle(int a, int b){
if(a == b) return 1;
if(a == 1){
if(b == 5) return 0;
if(b == 4) return 3;
if(b == 3) return 0;
if(b == 2) return 3;
}
if(a == 2){
if(b == 5) return 3;
if(b == 4) return 0;
if(b == 3) return 3;
}
if(a == 3){
if(b == 5) return 0;
if(b == 4) return 3;
}
if(a == 4){
if(b == 5) return 3;
}
return abs(battle(b, a) - 3);
}
int main() {
cin.tie(0);
int n, f, s;
string p1, s2;
cin >> n;
for(int i = 0; i < n; i++){
cin >> p1 >> s2;
string ans;
if(p1 == "tesoura") f = 1;
else if(p1 == "papel") f = 2;
else if(p1 == "pedra") f = 3;
else if(p1 == "lagarto") f = 4;
else if(p1 == "Spock") f = 5;
if(s2 == "tesoura") s = 1;
else if(s2 == "papel") s = 2;
else if(s2 == "pedra") s = 3;
else if(s2 == "lagarto") s = 4;
else if(s2 == "Spock") s = 5;
if(battle(f, s) == 0) ans += "Raj trapaceou!";
else if(battle(f, s) == 1) ans += "De novo!";
else if(battle(f, s) == 3) ans += "Bazinga!";
cout << "Caso #" << i+1 << ": " << ans << "\n";
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment