Hoof, Paper, Scissors, USACO Bronze
http://www.usaco.org/index.php?page=viewproblem2&cpid=688
Question
I have no idea why my solution code is failing even the first test case. It’s supposed to output 2, but it’s not outputting anything!
What I’ve Tried
I tried running it in ide.usaco.guide, and the test case works there, but it doesn’t work in usaco.org.
My Work
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("hps.in");
ofstream fout("hps.out");
int main() {
int n;
int cowa[200];
int cowb[200];
bool type1[3][3] = {{false, false, true}, {true, false, false}, {false, true, false}};
bool type2[3][3] = {{false, true, false}, {false, false, true}, {true, false, false}};
cin >> n;
for (int i = 0; i < n; i++) {
cin >> cowa[i] >> cowb[i];
}
int tot1 = 0;
int tot2 = 0;
for (int i = 0; i < n; i++) {
if (type1[cowa[i]-1][cowb[i]-1]) {
tot1 ++;
}
if (type2[cowa[i]-1][cowb[i]-1]) {
tot2 ++;
}
}
cout << max(tot1, tot2) << endl;
}
My code is basically brute forcing all of the permutations of hoof, paper scissors to see which one provides the largest number of wins.