USACO Silver 2016 December - Moocast

Authors: Óscar Garries (C++), Dong Liu (Python), Owen Wang (Java)

Official Analysis

C++

Implementation

#include <bits/stdc++.h>
using namespace std;
vector<vector<bool>> isConnected(201, vector<bool>(201));
vector<int> g[201];
vector<bool> visited(201);
int n;
int dfs (int v) {

Python

import sys
sys.stdin = open("moocast.in", 'r')
sys.stdout = open("moocast.out", 'w')
def dfs(v):
visited[v] = True
count = 1
for u in range(n):
if visited[u] or not canReach[v][u]:

Java

import java.io.*;
import java.util.*;
public class moocast {
static int N;
static Cow[] cows;
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new FileReader("moocast.in"));

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!