Submission #898769

# Submission time Handle Problem Language Result Execution time Memory
898769 2024-01-05T05:40:38 Z vjudge1 Magic Tree (CEOI19_magictree) C++17
0 / 100
37 ms 27740 KB
#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;
        if(adj[x].size() == 1) 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 Incorrect 26 ms 27740 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 23900 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 37 ms 27692 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 8 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 -