Submission #777422

#TimeUsernameProblemLanguageResultExecution timeMemory
777422The_SamuraiVinjete (COI22_vinjete)C++17
27 / 100
3051 ms524288 KiB
#pragma GCC optimize("Ofast") #pragma GCC optimize ("unroll-loops") #pragma GCC target("avx,avx2") #include "bits/stdc++.h" using namespace std; int n, m; vector<int> cnt, ans; vector<vector<tuple<int, int, int>>> g; void dfs(int u, int p, int l, int r) { for (int i = l; i <= r; i++) cnt[i]++; for (int i = 1; i <= m; i++) ans[u] += cnt[i] > 0; for (auto [v, lx, rx]: g[u]) { if (v != p) { dfs(v, u, lx, rx); } } for (int i = l; i <= r; i++) cnt[i]--; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n >> m; g.assign(n + 1, {}); ans.assign(n + 1, 0); cnt.assign(m + 1, 0); for (int i = 1; i < n; i++) { int u, v, l, r; cin >> u >> v >> l >> r; g[u].emplace_back(v, l, r); g[v].emplace_back(u, l, r); } dfs(1, 0, 1, 0); for (int i = 2; i <= n; i++) cout << ans[i] << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...