Submission #408373

#TimeUsernameProblemLanguageResultExecution timeMemory
408373muhammad_hokimiyonStations (IOI20_stations)C++14
Compilation error
0 ms0 KiB
#include "stations.h" #include <vector> #include<bits/stdc++.h> using namespace std; const int N = 1e3 + 7; int d[N]; vector<int> v[N]; void dfs(int x, int p) { for(auto y : v[x]){ if(y == p)continue; d[y] = d[x] + 1; dfs(y, x); } } std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) { std::vector<int> labels(n); for(int i = 0; i < n - 1; i++){ int x = u[i], y = v[i]; v[x].push_back(y); v[y].push_back(x); } int st = 0; for(int i = 1; i < n; i++){ if((int)v[i].size() < (int)v[st].size()){ st = i; } } dfs(st, st); for(int i = 0; i < n; i++){ labels[i] = d[i]; } return labels; } int find_next_station(int s, int t, std::vector<int> c) { for(auto x : c){ if(s < t && x < s)return x; if(s > t && x > s)return x; } assert(0); }

Compilation message (stderr)

stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:25:14: error: request for member 'push_back' in 'v.std::vector<int>::operator[](((std::vector<int>::size_type)x))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   25 |         v[x].push_back(y);
      |              ^~~~~~~~~
stations.cpp:26:14: error: request for member 'push_back' in 'v.std::vector<int>::operator[](((std::vector<int>::size_type)y))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   26 |         v[y].push_back(x);
      |              ^~~~~~~~~
stations.cpp:30:22: error: request for member 'size' in 'v.std::vector<int>::operator[](((std::vector<int>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   30 |         if((int)v[i].size() < (int)v[st].size()){
      |                      ^~~~
stations.cpp:30:42: error: request for member 'size' in 'v.std::vector<int>::operator[](((std::vector<int>::size_type)st))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   30 |         if((int)v[i].size() < (int)v[st].size()){
      |                                          ^~~~