Submission #867410

#TimeUsernameProblemLanguageResultExecution timeMemory
867410HuyQuang_re_ZeroRace (IOI11_race)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define ll long long #define db long double #define N 200005 #define II pair <ll,ll> #define III pair <ll,II> #define IV pair <vector <int>,vector <int> > #define fst first #define snd second #define BIT(x,i) ((x>>i)&1) #define pi acos(-1) #define to_radian(x) (x*pi/180.0) #define to_degree(x) (x*180.0/pi) #include "race.h" using namespace std; map <ll,ll> mp,in4[N]; vector <II> a[N]; ll h[N],w[N],sz[N],i,u,v,m,res; const ll oo=round(1e18); void dfs(int u,int p) { sz[u]=1; for(II adj:a[u]) { int v=adj.fst; if(v!=p) { h[v]=h[u]+1,w[v]=w[u]+adj.snd; dfs(v,u),sz[u]+=sz[v]; } } } //wu+wv-2*wlca=m //=>wv=m+2*wlca-wu void cal(ll wu,ll hu,int lca) { // if(lca==6 && hu==2 && wu==6) if(mp.count(m+2*w[lca]-wu)) res=min(res,hu+mp[m+2*w[lca]-wu]-2*h[lca]); } void add(ll w,ll h) { if(!mp.count(w)) mp[w]=h; else mp[w]=min(mp[w],h); } void DFS(int u,int p) { int x=0; for(II adj:a[u]) { int v=adj.fst; if(v!=p && sz[x]<sz[v]) x=v; } for(II adj:a[u]) { int v=adj.fst; if(v!=p && v!=x) { DFS(v,u); in4[v]=mp; mp.clear(); } } if(x>0) DFS(x,u); cal(w[u],h[u],u); add(w[u],h[u]); for(II adj:a[u]) { int v=adj.fst; if(v==p || v==x) continue; for(auto x:in4[v]) cal(x.fst,x.snd,u); for(auto x:in4[v]) add(x.fst,x.snd); } } ll best_path(int N,int K,int H[][2],int L[]) { m=K; for(i=0;i<N-1;i++) { int u=H[i][0]+1,v=H[i][1]+1,k=L[i]; // cerr<<u<<" "<<v<<'\n'; a[u].push_back({ v,k }); a[v].push_back({ u,k }); } res=oo; dfs(1,0); DFS(1,0); return (res==oo) ? -1 : res; } /* int main() { freopen("race.inp","r",stdin); freopen("race.out","w",stdout); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n,m; cin>>n>>m; int H[n+1][2],L[n+1]; for(int i=0;i<n-1;i++) cin>>H[i][0]>>H[i][1]>>L[i]; cout<<best_path(n,m,H,L); } */

Compilation message (stderr)

race.cpp:4:11: error: expected ',' or '...' before numeric constant
    4 | #define N 200005
      |           ^~~~~~
race.h:1:19: note: in expansion of macro 'N'
    1 | int best_path(int N, int K, int H[][2], int L[]);
      |                   ^
race.cpp:4:11: error: expected ',' or '...' before numeric constant
    4 | #define N 200005
      |           ^~~~~~
race.cpp:73:18: note: in expansion of macro 'N'
   73 | ll best_path(int N,int K,int H[][2],int L[])
      |                  ^
race.cpp:73:4: error: ambiguating new declaration of 'long long int best_path(int)'
   73 | ll best_path(int N,int K,int H[][2],int L[])
      |    ^~~~~~~~~
In file included from race.cpp:14:
race.h:1:5: note: old declaration 'int best_path(int)'
    1 | int best_path(int N, int K, int H[][2], int L[]);
      |     ^~~~~~~~~
race.cpp: In function 'long long int best_path(int)':
race.cpp:75:7: error: 'K' was not declared in this scope
   75 |     m=K;
      |       ^
race.cpp:78:15: error: 'H' was not declared in this scope
   78 |         int u=H[i][0]+1,v=H[i][1]+1,k=L[i];
      |               ^
race.cpp:80:28: error: 'k' was not declared in this scope
   80 |         a[u].push_back({ v,k });
      |                            ^
race.cpp:80:31: error: no matching function for call to 'std::vector<std::pair<long long int, long long int> >::push_back(<brace-enclosed initializer list>)'
   80 |         a[u].push_back({ v,k });
      |                               ^
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from race.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::pair<long long int, long long int>; _Alloc = std::allocator<std::pair<long long int, long long int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<long long int, long long int>]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1187:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::pair<long long int, long long int>&'}
 1187 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::pair<long long int, long long int>; _Alloc = std::allocator<std::pair<long long int, long long int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<long long int, long long int>]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1203:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<std::pair<long long int, long long int> >::value_type&&' {aka 'std::pair<long long int, long long int>&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
race.cpp:81:31: error: no matching function for call to 'std::vector<std::pair<long long int, long long int> >::push_back(<brace-enclosed initializer list>)'
   81 |         a[v].push_back({ u,k });
      |                               ^
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from race.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::pair<long long int, long long int>; _Alloc = std::allocator<std::pair<long long int, long long int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<long long int, long long int>]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1187:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::pair<long long int, long long int>&'}
 1187 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::pair<long long int, long long int>; _Alloc = std::allocator<std::pair<long long int, long long int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<long long int, long long int>]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1203:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<std::pair<long long int, long long int> >::value_type&&' {aka 'std::pair<long long int, long long int>&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~