Submission #601079

#TimeUsernameProblemLanguageResultExecution timeMemory
601079MeloricRace (IOI11_race)C++14
Compilation error
0 ms0 KiB
//#include "race.h" #include <bits/stdc++.h> #define pb push_back #define ll int64_t #define pii pair<int64_t, int64_t> #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 ll inf = 1e18; 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; } ll find(ll 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; } ll 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[]) { ll n = N; ll k = K; vector<vector<pii>> g(n, vector<pii>()); for(ll i = 0; i< n-1; i++){ ll c = H[i][0]; ll d = H[i][1]; ll w = L[i]; g[c].pb({d, w}); g[d].pb({c, w}); } ll ret = inf; auto dfs = [&](auto&& self, ll u, ll p)->special_set&{ //cout << u << endl; special_set S = new special_set(); S.insert({0, 0}); vector<pii> V; for(auto [v, w] : g[u])if(v!=p){ special_set O = self(self, v, u); O.update(make_pair(w, 1ll)); if(S.size() < O.size())swap(S, O); while(O.size()){ pii e = O.pop(); //cout << u << ' '<< e.X << ' '<< e.Y << ' ' << endl; ret = min(ret, e.Y+S.find(k-e.X)); V.pb(e); //S.insert(e); } for(auto e : V)S.insert(e); } return S; }; auto S = dfs(dfs, 0, 0); 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:72:13: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   72 |    for(auto [v, w] : g[u])if(v!=p){
      |             ^
race.cpp: In instantiation of 'best_path(int, int, int (*)[2], int*)::<lambda(auto:2&&, int64_t, int64_t)> [with auto:2 = best_path(int, int, int (*)[2], int*)::<lambda(auto:2&&, int64_t, int64_t)>&; int64_t = long int]':
race.cpp:88:25:   required from here
race.cpp:69:20: error: conversion from 'special_set*' to non-scalar type 'special_set' requested
   69 |    special_set S = new special_set();
      |                    ^~~~~~~~~~~~~~~~~
race.cpp:86:11: warning: reference to local variable 'S' returned [-Wreturn-local-addr]
   86 |    return S;
      |           ^
race.cpp:69:16: note: declared here
   69 |    special_set S = new special_set();
      |                ^