Submission #110448

#TimeUsernameProblemLanguageResultExecution timeMemory
110448ioilolcomDreaming (IOI13_dreaming)C++14
Compilation error
0 ms0 KiB
#include "dreaming.h" #include <bits/stdc++.h> #define y second #define x first #define ll long long int #define pb push_back #define pii pair<int,int> using namespace std; const int N=1e5+7; vector<pair<int,int> > adj[N]; bool vis[N]; void dfs(int node,int p,int length,pii &ans){ vis[node]=1; for(auto vertice:adj[node]) { if(vertice.x==p) { continue; } dfs(vertice.x,node,length+vertice.y,ans); } if(length>ans.y) { ans.x=node; ans.y=length; } } bool fn(int s,int e,int p,vector<int> &path){ if(s==e) { return true; } for(auto v:adj[s]) { if(v.x==p) continue; if(fn(v.x,e,s,path)) { path.push_back(v.x); return true; } } return false; } int travelTime(int N, int M, int L, int A[], int B[], int T[]) { int n=N; int m=M; int l=L; vector<int> radius; map<pair<int,int>,int> cost; for(int i=0; i<M; i++) { int u=A[i]; int v=B[i]; int w=T[i]; adj[u].pb({v,w}); adj[v].pb({u,w}); cost[{u,v}]=cost[{v,u}]=w; } int d=0; vector<pii> ans; for(int i=0; i<n; i++) { if(vis[i]) continue; pii s={-1,-1}; dfs(i,-1,0,s); pii e={-1,-1}; dfs(s.first,-1,0,e); int diameter=e.y; vector<int> path; fn(s.x,e.x,0,path); int sz=(int)path.size(); int radius=diameter; int center=i; int cur=diameter; d=max(d,diameter); for(int j=1; j<sz; j++) { cur-=cost[{path[j],path[j-1]}]; int vv=max(diameter-cur,cur); if(vv<radius) { center=path[j]; radius=vv; } } ans.push_back({center,radius}); } int node=0; int mx=-1; for(auto v:ans) { if(v.y>mx) { node=v.x; mx=v.y; } } for(auto v:ans) { if(v.x!=node) { //edges.push_back({v.f,node}); adj[v.x].push_back(node); adj[node].push_back(v.x); } } pii z={-1,-1}; dfs(1,0,0,z); pii zz={-1,-1}; dfs(z.x,0,0,zz); return zz.y; }

Compilation message (stderr)

dreaming.cpp: In function 'int travelTime(int, int, int, int*, int*, int*)':
dreaming.cpp:90:27: error: no matching function for call to 'std::vector<std::pair<int, int> >::push_back(int&)'
    adj[v.x].push_back(node);
                           ^
In file included from /usr/include/c++/7/vector:64:0,
                 from /usr/include/c++/7/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86,
                 from dreaming.cpp:2:
/usr/include/c++/7/bits/stl_vector.h:939:7: note: candidate: void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, int>]
       push_back(const value_type& __x)
       ^~~~~~~~~
/usr/include/c++/7/bits/stl_vector.h:939:7: note:   no known conversion for argument 1 from 'int' to 'const value_type& {aka const std::pair<int, int>&}'
/usr/include/c++/7/bits/stl_vector.h:953:7: note: candidate: void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, int>]
       push_back(value_type&& __x)
       ^~~~~~~~~
/usr/include/c++/7/bits/stl_vector.h:953:7: note:   no known conversion for argument 1 from 'int' to 'std::vector<std::pair<int, int> >::value_type&& {aka std::pair<int, int>&&}'
dreaming.cpp:91:27: error: no matching function for call to 'std::vector<std::pair<int, int> >::push_back(int&)'
    adj[node].push_back(v.x);
                           ^
In file included from /usr/include/c++/7/vector:64:0,
                 from /usr/include/c++/7/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86,
                 from dreaming.cpp:2:
/usr/include/c++/7/bits/stl_vector.h:939:7: note: candidate: void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, int>]
       push_back(const value_type& __x)
       ^~~~~~~~~
/usr/include/c++/7/bits/stl_vector.h:939:7: note:   no known conversion for argument 1 from 'int' to 'const value_type& {aka const std::pair<int, int>&}'
/usr/include/c++/7/bits/stl_vector.h:953:7: note: candidate: void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, int>]
       push_back(value_type&& __x)
       ^~~~~~~~~
/usr/include/c++/7/bits/stl_vector.h:953:7: note:   no known conversion for argument 1 from 'int' to 'std::vector<std::pair<int, int> >::value_type&& {aka std::pair<int, int>&&}'
dreaming.cpp:40:6: warning: unused variable 'm' [-Wunused-variable]
  int m=M;
      ^
dreaming.cpp:41:6: warning: unused variable 'l' [-Wunused-variable]
  int l=L;
      ^