This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |