USACO Silver 2019 January - Grass Planting

Author: Neo Wang

Problem Statement

Official Analysis

Java

Solution 1 (Java)

Time Complexity: O(N)\mathcal{O}(N)

import java.io.*;
import java.util.StringTokenizer;
public class GrassPlanting {
public static void main(String[] args) throws IOException {
Kattio io = new Kattio("planting");
int n = io.nextInt();
int[] deg = new int[n+1];
for(int i = 0; i < n-1; i++) {
int a = io.nextInt(), b = io.nextInt();

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!