#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';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
61 ms |
8264 KB |
Output is correct |
2 |
Correct |
56 ms |
7876 KB |
Output is correct |
3 |
Correct |
116 ms |
9924 KB |
Output is correct |
4 |
Correct |
97 ms |
9352 KB |
Output is correct |
5 |
Correct |
109 ms |
9720 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
296 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
111 ms |
9164 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
8 ms |
1764 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |