Submission #502505

#TimeUsernameProblemLanguageResultExecution timeMemory
502505InternetPerson10Magic Tree (CEOI19_magictree)C++17
3 / 100
116 ms9924 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { int n, m, k; cin >> n >> m >> k; vector<vector<int>> adj(n); vector<ll> weight(n); vector<int> day(n); bool isLine = true; for(int i = 1; i < n; i++) { int x; cin >> x; x--; adj[i].push_back(x); adj[x].push_back(i); if(x != i-1) isLine = false; } int maxWeight = -1, maxDay = -1, maxAdj = -1; for(int i = 0; i < m; i++) { int v, d, w; cin >> v >> d >> w; v--; weight[v] = w; day[v] = d; maxWeight = max(maxWeight, w); maxDay = max(maxDay, d); maxAdj = max(maxAdj, (int)adj[v].size()); } ll ans = 0; if(n <= 20 && k <= 20 && maxWeight == 1) { } else if(maxAdj == 1) { for(int w : weight) ans += w; } else if(isLine && maxWeight == 1) { } else if(k <= 2) { } else if(k <= 20 && maxAdj == 1) { } else if(m <= 1000) { } else if(maxWeight == 1) { } else { } cout << ans << '\n'; }
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...