Submission #312376

#TimeUsernameProblemLanguageResultExecution timeMemory
312376jainbot27Stations (IOI20_stations)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define f first #define s second #define pb push_back #define ar array #define all(x) x.begin(), x.end() #define siz(x) (int)x.size() #define FOR(x, y, z) for(int x = (y); x < (z); x++) #define ROF(x, z, y) for(int x = (y-1); x >= (z); x--) #define F0R(x, z) FOR(x, 0, z) #define R0F(x, z) ROF(x, 0, z) #define trav(x, y) for(auto&x:y) using ll = long long; using vi = vector<int>; using vl = vector<long long>; using pii = pair<int, int>; using vpii = vector<pair<int, int>>; template<class T> inline bool ckmin(T&a, T b) {return b < a ? a = b, 1 : 0;} template<class T> inline bool ckmax(T&a, T b) {return b > a ? a = b, 1 : 0;} mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const char nl = '\n'; const int mxN = 2e5 + 10; const int MOD = 1e9 + 7; const long long infLL = 1e18; vi res; int tot = 0; int n, k; vi u, v; vector<vi> adj; void dfs(int U, int P, int T){ if(!T) res[V] = ++tot; trav(V, adj[U]){ if(V == P) continue; dfs(V, U, T^1); } if(T) res[v] = tot; } vi label(int N, int K, vi U, vi V){ n = N, k = K, u = U, v = V; res.resize(n); adj.resize(n); F0R(i, n-1){ adj[u[i]].pb(v[i]); adj[v[i]).pb(u[i]); } dfs(0, -1, 0); return res; } int find_next_station(int s, int t, vi c){ trav(x, c) if(min(x, s) <= t && max(x, s) >= t) return x; return c[0]; }

Compilation message (stderr)

stations.cpp: In function 'void dfs(int, int, int)':
stations.cpp:36:16: error: 'V' was not declared in this scope
   36 |     if(!T) res[V] = ++tot;
      |                ^
stations.cpp:41:14: error: no match for 'operator[]' (operand types are 'vi' {aka 'std::vector<int>'} and 'vi' {aka 'std::vector<int>'})
   41 |     if(T) res[v] = tot;
      |              ^
In file included from /usr/include/c++/9/vector:67,
                 from /usr/include/c++/9/functional:62,
                 from /usr/include/c++/9/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/9/algorithm:71,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from stations.cpp:1:
/usr/include/c++/9/bits/stl_vector.h:1040:7: note: candidate: 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::reference = int&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]'
 1040 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/9/bits/stl_vector.h:1040:28: note:   no known conversion for argument 1 from 'vi' {aka 'std::vector<int>'} to 'std::vector<int>::size_type' {aka 'long unsigned int'}
 1040 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
/usr/include/c++/9/bits/stl_vector.h:1058:7: note: candidate: 'std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) const [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::const_reference = const int&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]'
 1058 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/9/bits/stl_vector.h:1058:28: note:   no known conversion for argument 1 from 'vi' {aka 'std::vector<int>'} to 'std::vector<int>::size_type' {aka 'long unsigned int'}
 1058 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
stations.cpp: In function 'vi label(int, int, vi, vi)':
stations.cpp:48:17: error: expected ']' before ')' token
   48 |         adj[v[i]).pb(u[i]);
      |                 ^
      |                 ]
stations.cpp:48:17: error: expected ';' before ')' token
   48 |         adj[v[i]).pb(u[i]);
      |                 ^
      |                 ;