USACO Silver 2017 January - Hoof, Paper, Scissors

Authors: Óscar Garries, Owen Wang, Juheon Rhee


Official Analysis (Java)

C++

Implementation

#include <bits/stdc++.h>
using namespace std;
int main() {
freopen("hps.in", "r", stdin);
int n;
cin >> n;
vector<int> hooves(n + 1), paper(n + 1), scissors(n + 1);

Java

Implementation

import java.io.*;
public class HPS {
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new FileReader("hps.in"));
int n = Integer.parseInt(br.readLine());
int[] hooves = new int[n + 1];
int[] paper = new int[n + 1];
int[] scissors = new int[n + 1];

Python

with open("hps.in") as r:
n = int(r.readline().strip())
hooves = [0 for _ in range(n + 1)]
paper = [0 for _ in range(n + 1)]
scissors = [0 for _ in range(n + 1)]
for i in range(1, n + 1):
hooves[i] += hooves[i - 1]
paper[i] += paper[i - 1]
scissors[i] += scissors[i - 1]

Join the USACO Forum!

Stuck on a problem, or don't understand a module? Join the USACO Forum and get help from other competitive programmers!