Submission #600198

#TimeUsernameProblemLanguageResultExecution timeMemory
600198MeloricRace (IOI11_race)C++14
Compilation error
0 ms0 KiB
#include "race.h" #include <bits/stdc++.h> #define pb push_back #define int int64_t #define pii pair<int, int> #define X first #define Y second #define all(x) (x).begin(),(x).end() #define lb lower_bound #define ub upper_bound using namespace std; const int inf = 1e9; void p(auto A){ for(auto e : A)cout << e << ' '; cout << '\n'; } struct special_set{ set<pii> S; pii delta = {0, 0}; void insert(pii e){ S.insert({e.X-delta.X, e.Y-delta.Y}); } void update(pii dx){ delta.X+=dx.X; delta.Y+=dx.Y; } int find(int x){ x-=delta.X; if(S.lb({x, -inf}) == S.end())return inf; if(S.lb({x, -inf})->X != x)return inf; return S.lb({x, -inf})->Y+delta.Y; } pii pop(){ pii ret = *S.begin(); S.erase(S.begin()); ret.X+=delta.X; ret.Y+=delta.Y; return ret; } int size(){ return S.size(); } void p(){ //for(auto [e, f] : S)cout << e+delta.X << ' '<< f+delta.Y << endl; } }; int best_path(int N, int K, int H[][2], int L[]) { int n = N; int k = K; vector<vector<pii>> g(n, vector<pii>()); for(int i = 0; i< n-1; i++){ int c = H[i][0]; int d = H[i][1]; int w = L[i]; g[c].pb({d, w}); g[d].pb({c, w}); } int ret = inf; auto dfs = [&](auto&& self, int u, int p)->special_set{ //cout << u << endl; special_set S; S.insert({0, 0}); for(auto [v, w] : g[u])if(v!=p){ special_set O = self(self, v, u); O.update(make_pair(w, 1)); if(S.size() < O.size())swap(S, O); if(u == 0)S.p(); while(O.size()){ pii e = O.pop(); //cout << u << ' '<< e.X << ' '<< e.Y << ' ' << endl; ret = min(ret, e.Y+S.find(k-e.X)); S.insert(e); } } return S; }; auto S = dfs(dfs, 0, 0); while(S.size()){ auto e = S.pop(); //cout << e.X << ' '<< e.Y << ' '; } if(ret == inf)return -1; return ret; } /* void solve(){ int N, K, H[100][2], L[100]; cin >> N >> K; for(int i = 0; i< N-1; i++){ cin >> H[i][0] >> H[i][1] >> L[i]; } cout << best_path(N, K, H, L); } signed main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int t = 1; //cin >> t; while(t--)solve(); } */

Compilation message (stderr)

race.cpp:17:8: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   17 | void p(auto A){
      |        ^~~~
race.cpp: In lambda function:
race.cpp:71:13: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   71 |    for(auto [v, w] : g[u])if(v!=p){
      |             ^
race.cpp: In function 'int64_t best_path(int64_t, int64_t, int64_t (*)[2], int64_t*)':
race.cpp:88:9: warning: variable 'e' set but not used [-Wunused-but-set-variable]
   88 |    auto e = S.pop();
      |         ^
/usr/bin/ld: /tmp/ccUjsfHO.o: in function `main':
grader.cpp:(.text.startup+0x28): undefined reference to `best_path(int, int, int (*) [2], int*)'
collect2: error: ld returned 1 exit status