Submission #321675

#TimeUsernameProblemLanguageResultExecution timeMemory
321675GilgameshStations (IOI20_stations)C++17
Compilation error
0 ms0 KiB
#include "stations.h" #include <bits/stdc++.h> using namespace std; const int mxN = 1'001; vector<int> adj[mxN]; int timer; int temp[mxN]; void dfs(int v, int p){ temp[timer++] = v; for(int i : adj[v]) { if(i == p) continue; dfs(i, v); } } vector<int> label(int n, int k, vector<int> u, vector<int> v) { vector<int> labels(n); for(int i = 0; i < n - 1; ++i){ adj[u[i]].emplace_back(adj[v[i]]); adj[v[i]].emplace_back(adj[u[i]]); } timer = 0; dfs(0, -1); for(int i = 0; i < n; ++i){ labels[i] = temp[i]; } return labels; } int find_next_station(int s, int t, vector<int> c) { sort(c.begin(), c.end()); if(t < s) { return c[0]; } else { int ans = 0; for(int i : c){ if(t < i) break; ans = i; } return ans; } } //int main(){}

Compilation message (stderr)

In file included from /usr/include/x86_64-linux-gnu/c++/9/bits/c++allocator.h:33,
                 from /usr/include/c++/9/bits/allocator.h:46,
                 from /usr/include/c++/9/vector:64,
                 from stations.h:1,
                 from stations.cpp:1:
/usr/include/c++/9/ext/new_allocator.h: In instantiation of 'void __gnu_cxx::new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = int; _Args = {std::vector<int, std::allocator<int> >&}; _Tp = int]':
/usr/include/c++/9/bits/alloc_traits.h:482:2:   required from 'static void std::allocator_traits<std::allocator<_Tp1> >::construct(std::allocator_traits<std::allocator<_Tp1> >::allocator_type&, _Up*, _Args&& ...) [with _Up = int; _Args = {std::vector<int, std::allocator<int> >&}; _Tp = int; std::allocator_traits<std::allocator<_Tp1> >::allocator_type = std::allocator<int>]'
/usr/include/c++/9/bits/vector.tcc:115:30:   required from 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {std::vector<int, std::allocator<int> >&}; _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::reference = int&]'
stations.cpp:22:35:   required from here
/usr/include/c++/9/ext/new_allocator.h:145:20: error: cannot convert 'std::vector<int>' to 'int' in initialization
  145 |  noexcept(noexcept(::new((void *)__p)
      |                    ^~~~~~~~~~~~~~~~~~
  146 |        _Up(std::forward<_Args>(__args)...)))
      |        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~