Submission #551542

#TimeUsernameProblemLanguageResultExecution timeMemory
551542krit3379Rail (IOI14_rail)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; #define N 5005 struct A{ int x,id; bool operator<(const A& o)const{ return x<o.x; } }; A l,r; vector<A> v; map<int,int> mp; void findLocation(int n, int first, int location[], int stype[]){ int i,pos; location[0]=first; stype[0]=1; if(n==1)return ; l={first,0}; mp[l.x]=1; for(i=1;i<n;i++)v.push_back({getDistance(0,i),i}); sort(v.begin(),v.end()); r={l.x+v[0].x,v[0].id}; location[v[0].id]=r.x; stype[v[0].id]=2; mp[r.x]=2; for(i=1;i<v.size();i++){ int xl,xr; xl=getDistance(v[i].id,l.id); xr=getDistance(v[i].id,r.id); pos=l.x+xl; int val=(pos+r.x-xr)/2; if((mp.count(val)&&mp[val]==1)||(!mp.count(val)&&val>first)){ A temp={pos,v[i].id}; location[v[i].id]=pos; stype[v[i].id]=2; r=max(r,temp); mp[pos]=2; continue; } pos=r.x-xr; A temp={pos,v[i].id}; location[v[i].id]=pos; stype[v[i].id]=1; l=min(l,temp); mp[pos]=1; } return ; }

Compilation message (stderr)

rail.cpp: In function 'void findLocation(int, int, int*, int*)':
rail.cpp:23:34: error: 'getDistance' was not declared in this scope
   23 |     for(i=1;i<n;i++)v.push_back({getDistance(0,i),i});
      |                                  ^~~~~~~~~~~
rail.cpp:23:53: error: no matching function for call to 'std::vector<A>::push_back(<brace-enclosed initializer list>)'
   23 |     for(i=1;i<n;i++)v.push_back({getDistance(0,i),i});
      |                                                     ^
In file included from /usr/include/c++/10/vector:67,
                 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 rail.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 = A; _Alloc = std::allocator<A>; std::vector<_Tp, _Alloc>::value_type = A]'
 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 A&'}
 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 = A; _Alloc = std::allocator<A>; std::vector<_Tp, _Alloc>::value_type = A]'
 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<A>::value_type&&' {aka 'A&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
rail.cpp:29:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<A>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |     for(i=1;i<v.size();i++){
      |             ~^~~~~~~~~
rail.cpp:31:12: error: 'getDistance' was not declared in this scope
   31 |         xl=getDistance(v[i].id,l.id);
      |            ^~~~~~~~~~~