Submission #569341

#TimeUsernameProblemLanguageResultExecution timeMemory
569341EdilRoad Closures (APIO21_roads)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define vct vector <int> struct ed { ll x = 0; set <ll> y; }; bool cmp(ed a, ed b) { if(a.x == b.x) return a.y > b.y; return a.x > b.x; } vector <ll> minimum_closure_costs(int n, vct u, vct v, vct w) { n++; ll sm = 0; vector <ll> ans(n); vector <ed> tr(n); for(ll i = 0; i < (ll)w.size(); i++) { tr[u[i]].x++; tr[v[i]].x++; tr[u[i]].y.insert(w[i]); tr[v[i]].y.insert(w[i]); sm += w[i]; } ans[0] = sm; sm = 0; sort(tr.begin(), tr.end(), cmp); for(ll k = n; k > 0; k--) { ll sm2 = sm; sm = 0; for(ll i = 0; tr[i].x > k; i++) { tr[i].x--; sm += *tr[i].y.begin(); tr[i].y.erase(tr[i].y.begin()); } ans[k] = sm + sm2; } return ans; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ll n; cin >> n; n--; vector <int> u(n), v(n), w(n); for(int i = 0; i < n; i++) cin >> u[i] >> v[i] >> w[i]; vector <ll> a; a = minimum_closure_costs(n, u, v, w); for(ll i : a) cout << i << " "; }

Compilation message (stderr)

/usr/bin/ld: /tmp/ccquLxx0.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccQP3KD1.o:roads.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status