Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- vector<vector<T>>(m, vector<T>(n)); }
- template <class T, T init> inline auto vv(int m) { return vector<vector<T>>(m, vector<T>(m, init)); }
- template <class T, T init> inline auto vv(int m, int n) { return vector<vector<T>>(m, vector<T>(n, init)); }
- template <class T> using mpq = priority_queue<T, vector<T>, greater<T>>;
- using ll = long long;
- using pii = pair<int, int>;
- using vl = vector<ll>;
- using vi = vector<int>;
- int n;
- vi g[2048];
- pii dfs(int u, int pa)
- {
- int all = 0;
- int min_delta = INT_MAX / 2;
- for (auto v : g[u]) {
- if (v == pa)
- continue;
- auto [sw, swn] = dfs(v, u);
- all += min(sw, swn);
- min_delta = min(min_delta, sw - swn);
- }
- return {all + 1, all + (min_delta > 0 ? min_delta : 0)};
- }
- int main(int argc, char **argv)
- {
- cin >> n;
- for (int i = 0; i < n; ++i) {
- int u, v, k;
- cin >> u >> k;
- for (int
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement