#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define fort(itr,map) for(auto itr = map.begin(); itr != map.end(); ++itr)
#define pb push_back
#define elif else if
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define uni(v) sort(all(v)), v.erase(unique(all(v)), v.end())
#define int long long
const int MAX = 1e6;
const int INF = 1e9 + 7;
vector<int> adj[MAX];
main()
{IOS;
int n, m, k; cin >> n >> m >> k;
for(int i = 1; i < n; i++){
int p; cin >> p;
adj[i].pb(p);
adj[p].pb(i);
}
int ans = 0;
for(int i = 1; i <= m; i++){
int x, y, w; cin >> x >> y >> w;
ans += w;
}
cout << ans << endl;
}
Compilation message
magictree.cpp:19:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
19 | main()
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
23896 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
30 ms |
27740 KB |
Output is correct |
2 |
Correct |
25 ms |
27288 KB |
Output is correct |
3 |
Correct |
36 ms |
27996 KB |
Output is correct |
4 |
Correct |
30 ms |
27852 KB |
Output is correct |
5 |
Correct |
35 ms |
28252 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
23896 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
38 ms |
27596 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
23896 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
9 ms |
24668 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
23896 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
23896 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |