Submission #605703

#TimeUsernameProblemLanguageResultExecution timeMemory
605703MohamedAliSaidaneStations (IOI20_stations)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; typedef vector<int> vi; typedef vector<ll> vll; typedef vector<pii> vpi; typedef vector<pll> vpl; #define pb push_back #define popb pop_back #define all(x) (x).begin(),(x).end() #define ff first #define ss second const int nax = 1001; vi rep; int cureul = -1; vi adj[nax]; int in[nax], out[nax]; void dfs(int x, int d = 0, int p = -1) { in[x] = cureul++; for(auto e: adj[x]) if(e != p) dfs(e, d + 1, x); out[x] = cureul++; if(d & 1) rep[x] = out[x]; else rep[x] = in[x]; } vi label(int n, int k, vi u, vi v) { for(int i = 0 ; i < n; i++) adj[i].clear(); cureul = 0; rep.assign(n , 0); for(int i= 0; i < n - 1; i ++) { adj[u[i]].pb(v[i]); adj[v[i]].pb(u[i]); } dfs(0); vpi vec; for(int i = 0; i < n; i++) vec.pb({ans[i], i}); sort(all(vec)); for(int i = 0 ; i < n ;i++) ans[vec[i].ss] = i; return rep; } int find_next_station(int s, int t, vi c) { sort(all(c)); int sz = c.size(); bool ev = s < c[0]; int ini, outi; if(ev) { ini = s; if(s == 0) outi = 1999; else if(sz == 1) outi = ini + 1; else outi = c[sz - 2] + 1; if(t >= ini && t <= outi) { for(auto e: c) if(e >= t) return e; } else { return c[sz - 1]; } } else { outi = s; if(sz == 1) ini = outi; else ini = c[1] - 1; if(t >= ini && t <= outi) { reverse(all(c)); for(auto e: c) if(e <= t) return e; } else { return c[0]; } } }

Compilation message (stderr)

stations.cpp: In function 'vi label(int, int, vi, vi)':
stations.cpp:53:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
   53 |         vec.pb({ans[i], i});
      |                 ^~~
      |                 abs
stations.cpp:53:27: error: no matching function for call to 'std::vector<std::pair<int, int> >::push_back(<brace-enclosed initializer list>)'
   53 |         vec.pb({ans[i], i});
      |                           ^
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 stations.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<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, 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<int, 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<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, 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<int, int> >::value_type&&' {aka 'std::pair<int, int>&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
stations.cpp:56:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   56 |             ans[vec[i].ss]  = i;
      |             ^~~
      |             abs
stations.cpp: In function 'int find_next_station(int, int, vi)':
stations.cpp:106:5: warning: control reaches end of non-void function [-Wreturn-type]
  106 |     }
      |     ^