USACO Silver 2017 February - Why Did the Cow Cross the Road II
Authors: Albert Zhu, Juheon Rhee
Implementation
Time Complexity:
C++
#include <bits/stdc++.h>using namespace std;void setIO(string prob) {freopen((prob + ".in").c_str(), "r", stdin);freopen((prob + ".out").c_str(), "w", stdout);}const int MAX_N = 1e5;
Java
import java.io.*;import java.util.*;public class MaxCross {public static void main(String[] args) throws IOException {BufferedReader in = new BufferedReader(new FileReader("maxcross.in"));PrintWriter pw = new PrintWriter("maxcross.out");StringTokenizer st = new StringTokenizer(in.readLine());int n = Integer.parseInt(st.nextToken());
Python
with open("maxcross.in") as read:n, k, b = map(int, read.readline().split())seen = [0] * (n + 1)left, right = 1, kvalue = 0for _ in range(b):seen[int(read.readline())] = 1for i in range(left, right + 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!