# USACO 2015 US Open Bronze: 2. Bessie Gets Even

## Problem Info

USACO 2015 US Open Bronze: 2. Bessie Gets Even
My code only passes case 1, 2, and 3.

## My Work

``````#include <iostream> // the ide.usaco.guide automatically does <bits/std++.h>
using namespace std;
int main(){
freopen("geteven.in", "r", stdin);
freopen("geteven.out", "w", stdout);
int v;
for (int i = 0; i < 90; i++) v[i] = 0, v[i] = 0;
// initialize all values to zero
int n; cin >> n;
for (int i = 0; i < n; i++){
char c; cin >> c;
int t; cin >> t;
v[c][t%2]++; // 0 is even, 1 is odd
}

long long ans = 0;
//go through each even/odd possibility
for (int b = 0; b < 2; b++) for (int e = 0; e < 2; e++)
for (int s = 0; s < 2; s++) for (int i = 0; i < 2; i++)
for (int g = 0; g < 2; g++) for (int o = 0; o < 2; o++)
for (int m = 0; m < 2; m++)
if ( ((b+e+s+s+i+e)*(g+o+e+s)*(m+o+o))%2 == 0)
ans += v['B'][b]*v['E'][e]*v['S'][s]*v['I'][i]*v['G'][g]*v['O'][o]*v['M'][m];

cout << ans << "\n";
return 0;
}
``````

The code I used is practically the same as the official solution.

## What I’ve Tried

The test data is too large on the ones I’m failing on (n=140) to model by hand, and I haven’t been able to input a smaller testcase that fails. I’ve also updated my code to align with the tips @BongoCoder gave - Thanks! … But it still doesn’t work.

Edit: You need to do abs(t) % 2

1 Like

I’m silver, but I used Python to get there, and now I’ve started using C++. The more I use C++, the more I want to go back to Python (error tracebacks, no compile time), but sadly, I think Python is too slow for some problems. Thanks for your help!

1 Like