USACO Silver 2016 December - Moocast

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

Problem Statement

Official Analysis

C++

Implementation

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

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!