Submission #487208

#TimeUsernameProblemLanguageResultExecution timeMemory
487208aymanrs경주 (Race) (IOI11_race)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> //#include "race.h" #define ll long long #define pii pair<ll, ll> #define fi first #define se second #define pb push_back using namespace std; const ll MX=200007, INF=1e9+7; vector<pii> adj[MX]; map<ll, pii> ada[MX]; ll N, K, ret=INF; void add(ll i, ll j, ll x){ if(ada[i].count(j)){ pii now=ada[i][j]; if(now.se>x) now.se=x; if(now.fi>now.se) swap(now.fi, now.se); ada[i][j]=now; }else{ ada[i][j]={x, INF}; } } void DFS(ll par, ll wpar, ll x){ ada[x][0]={0, INF}; for(auto i:adj[x]){ ll v=i.fi, w=i.se; if(v==par) continue; DFS(x, w, v); if(ada[x].size()<ada[v].size()) swap(ada[x], ada[v]); for(auto j:ada[v]){ ll tot=j.fi, sisa=K-tot; pii cnt=j.se; if(tot>K) continue; if(ada[x].count(sisa)){ ret=min(ret, ada[x][sisa].fi+j.fi); } add(x, tot, cnt.fi); add(x, tot, cnt.se); } } vector<pair<ll, pii>> tambah; for(auto i=ada[x].rbegin(); i!=ada[x].rend(); i++){ pair<ll, pii> tmp=*i; tmp.se.fi++; tmp.se.se++; if(tmp.fi+wpar<=K) tambah.pb({tmp.fi+wpar, tmp.se}); } ada[x].clear(); for(auto i:tambah) ada[x][i.fi]=i.se; if(ada[x].count(K)) ret=min(ret, ada[x][K].fi); } int best_path(int n, int k, int H[][2], int L[]){ N=n, K=k; for(ll i=0, u, v, w; i<N-1; i++){ u=H[i][0], v=H[i][1], w=L[i]; adj[u].pb({v, w}); adj[v].pb({u, w}); } DFS(0, 0, 0); return (ret>=INF?-1:ret); } int main(){ int H[][2] = {{0, 1},{0, 2},{2, 3},{3, 4},{4, 5},{0, 6},{6, 7},{6, 8},{8, 9},{8, 10}}; int L[] = {3,4,5,4,6,3,2,5,6,7}; cout << best_path(11, 12, H, L) << '\n'; }

Compilation message (stderr)

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