제출 #877895

#제출 시각아이디문제언어결과실행 시간메모리
877895raul2008487경주 (Race) (IOI11_race)C++17
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> #include "race.h" #define ll long long #define pb push_back #define eb emplace_back #define vl vector<ll> #define fi first #define se second #define in insert #define mpr make_pair #define lg(x) __lg(x) #define bpc(x) __builtin_popcount(x) #define all(v) v.begin(), v.end() #define endl "\n" using namespace std; const int sz = 2e5+5; const ll inf = 1000000000000000; bool used[sz]; vector<pair<ll,ll>> arr, adj[sz]; ll n, k, ss[sz], res = inf; map<ll,ll> mp; void construct(ll node, ll p){ ss[node] = 1; for(pair<ll,ll> edge: adj[node]){ if(!used[edge.fi] && edge.fi != p){ construct(edge.fi, node); ss[node] += ss[edge.fi]; } } } ll centroid(ll v, ll p, ll cs){ for(pair<ll,ll> edge: adj[v]){ if(edge.fi == p || used[edge.fi]){continue;} if(ss[edge.fi] > (cs>>1)){ return centroid(edge.fi, v, cs); } } return v; } void init(ll v, ll p, ll w, ll we){ if(mp.find(k - w) != mp.end()){ res = min(res, mp[k-w] + we); } arr.eb({w, we}); for(pair<ll,ll> edge: adj[v]){ if(used[v] || edge.fi == p){continue;} init(edge.fi, v, w + edge.se, we + 1); } } void calc(ll node){ mp.clear(); construct(node, -1); ll c = centroid(node, -1, ss[node]); mp[0] = 0; for(pair<ll,ll> edge: adj[c]){ if(used[edge.fi]){continue;} arr.clear(); init(edge.fi, c, edge.se, 1); for(pair<ll,ll> y: arr){ if(mp.find(y.fi) == mp.end()){ mp[y.fi] = y.se; } else{ mp[y.fi] = min(mp[y.fi], y.se); } } } used[c] = 1; for(pair<ll,ll> edge: adj[c]){ if(!used[edge.fi]){ calc(edge.fi); } } } int best_path(int N, int K, int H[][2], int L[]) { n = N; k = K; for(i=0;i<n-1;i++){ adj[H[i][0]].pb({H[i][1], L[i]}); adj[H[i][1]].pb({H[i][0], L[i]}); } calc(0); if(res == inf){ return -1 } return res; }

컴파일 시 표준 에러 (stderr) 메시지

race.cpp: In function 'void init(long long int, long long int, long long int, long long int)':
race.cpp:44:19: error: no matching function for call to 'std::vector<std::pair<long long int, long long int> >::emplace_back(<brace-enclosed initializer list>)'
   44 |     arr.eb({w, we});
      |                   ^
In file included from /usr/include/c++/10/vector:72,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from race.cpp:1:
/usr/include/c++/10/bits/vector.tcc:109:7: note: candidate: 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {}; _Tp = std::pair<long long int, long long int>; _Alloc = std::allocator<std::pair<long long int, long long int> >; std::vector<_Tp, _Alloc>::reference = std::pair<long long int, long long int>&]'
  109 |       vector<_Tp, _Alloc>::
      |       ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/vector.tcc:109:7: note:   candidate expects 0 arguments, 1 provided
race.cpp: In function 'int best_path(int, int, int (*)[2], int*)':
race.cpp:79:9: error: 'i' was not declared in this scope
   79 |     for(i=0;i<n-1;i++){
      |         ^
race.cpp:85:18: error: expected ';' before '}' token
   85 |         return -1
      |                  ^
      |                  ;
   86 |     }
      |     ~