Official Analysis

Implementation

C++

#include <bits/stdc++.h>
using namespace std;
int N, time;
vector<int> add;
vector<int> edge[100005];
long long ans[100005];
void dfs(int ss, int a) {
ans[ss] += a;

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!