USACO Silver 2020 December - Cowntagion

Author: Kevin Sheng

Official Editorial

Java

import java.io.*;
import java.util.*;
public class Cowntagion {
@SuppressWarnings("unchecked") // don't worry, i totally know what i'm doing
public static void main(String[] args) throws IOException {
BufferedReader read = new BufferedReader(new InputStreamReader(System.in));
int farmNum = Integer.parseInt(read.readLine());
List<Integer>[] neighbors = new ArrayList[farmNum];
for (int f = 0; f < farmNum; f++) {

Python

from collections import deque
# straight from stackoverflow
def ceiLog2(x): # returns the smallest n so that 2^n >= x
return 1 if x == 0 else (x - 1).bit_length()
farmNum = int(input())
neighbors = [[] for _ in range(farmNum)]

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!