# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1090224 | 2024-09-18T03:56:22 Z | pmqwerty | Magic Tree (CEOI19_magictree) | C++17 | 0 ms | 0 KB |
#include<bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 100; vector<int> a[MAXN]; int par[MAXN]; int indegree[MAXN]; int outdegree[MAXN]; int n, m, k; pair<int, int> f[MAXN]; namespace sub2{ bool check(){ for (int i = 1; i <= m; i++){ if (outdegree[f[i].second] == 0){ return false; } } return true; } void solve(){ int ans = 0; for (int i = 1; i <= m; i++){ ans += w[i]; } cout << ans << '\n'; } } namespace sub1{ bool check(){ return n <= 20 && k <= 20; } void solve(){ for (int i = 1; i <= n; i++){ } } } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> m >> k; for (int i = 2; i <= n; i++){ int x; cin >> x; a[x].push_back(i); outdegree[x]++; indegree[x]++; } for (int i = 1; i <= m; i++){ cin >> f[i].first >> f[i].second; } if (sub2::check()) sub2::solve(); }