Submission #700851

#TimeUsernameProblemLanguageResultExecution timeMemory
700851kusmetliqRace (IOI11_race)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; const int maxN=200005; const long long big=100000000000000; long long k; long long minans=INT_MAX; vector<int>a[maxN]; map<pair<int,int>,int>dist; map<long long,long long>path; bool used[maxN]; int sz[maxN]; int upd_sz(int n,int parent=-1) { sz[n]=1; for(int i:a[n]) { if(i!=parent && used[i]==0)sz[n]+=upd_sz(i,n); } return sz[n]; } int find_cen(int n,int siz,int parent=-1) { for(int i:a[n]) { if(used[i]==0 && sz[i]>siz/2 && i!=parent)return find_cen(i,siz,n); } return n; } void upd_ans(int n,int depth,long long distance,int parent=-1) { if(k-distance>=0)minans=min(minans,depth+path[k-distance]+big); for(int i:a[n]) { if(used[i]==0 && i!=parent) { upd_ans(i,depth+1,distance+dist[{i,n}],n); } } } void upd_score(int n,int depth,long long distance,int parent=-1) { path[distance]=min(path[distance],depth-big); for(int i:a[n]) { if(used[i]==0 && i!=parent) { upd_score(i,depth+1,distance+dist[{i,n}],n); } } } void dfs(int n) { int c=find_cen(n,upd_sz(n)); used[c]=1; path.clear(); path[0]=-big; for(int i:a[c]) { if(used[i]==0) { upd_ans(i,1,dist[{c,i}]); upd_score(i,1,dist[{c,i}]); } } for(int i:a[c]) { if(used[i]==0)dfs(i); } } int bestpath(int N,long long K,vector<vector<int>>H,vector<int>L) { k=K; for(int i=0;i<N-1;i++) { a[H[i][0]].push_back(a[H[i][1]]); a[H[i][1]].push_back(a[H[i][0]]); dist[{H[i][0],H[i][1]}]=dist[{H[i][1],H[i][0]}]=L[i]; } dfs(0); if(minans==INT_MAX)return -1; else return minans; } /** int main() { int n; cin>>n>>k; for(int i=0;i<n-1;i++) { int z; int x,y;cin>>x>>y>>z; a[x].push_back(y); a[y].push_back(x); dist[{x,y}]=dist[{y,x}]=z; } dfs(0); if(minans==INT_MAX)cout<<-1<<endl; else cout<<minans<<endl; return 0; }*/ /** 4 3 0 1 1 1 2 2 1 3 4 */

Compilation message (stderr)

race.cpp: In function 'int bestpath(int, long long int, std::vector<std::vector<int> >, std::vector<int>)':
race.cpp:68:40: error: no matching function for call to 'std::vector<int>::push_back(std::vector<int>&)'
   68 |         a[H[i][0]].push_back(a[H[i][1]]);
      |                                        ^
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 = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::value_type = 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 'std::vector<int>' to 'const value_type&' {aka 'const 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 = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::value_type = 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 'std::vector<int>' to 'std::vector<int>::value_type&&' {aka 'int&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
race.cpp:69:40: error: no matching function for call to 'std::vector<int>::push_back(std::vector<int>&)'
   69 |         a[H[i][1]].push_back(a[H[i][0]]);
      |                                        ^
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 = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::value_type = 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 'std::vector<int>' to 'const value_type&' {aka 'const 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 = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::value_type = 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 'std::vector<int>' to 'std::vector<int>::value_type&&' {aka 'int&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~