Submission #1073769

#TimeUsernameProblemLanguageResultExecution timeMemory
1073769thatsgonzalezStations (IOI20_stations)C++14
Compilation error
0 ms0 KiB
#include "stations.h" #include <vector> #include <bits/stdc++.h> using namespace std; #define s second #define f first vector <int> sub_tree; vector <int> labels; vector <vector<int>> g; int mx , mn; int dfs(int node, int p){ for(auto &x: g[node]){ if(x == node) continue; sub_tree[node]+=dfs(x,node); } return sub_tree[node]=sub_tree[node]+1; } void calc_labels(int node, int p, int t){ if(t){ labels[node] = mn+sub_tree[node]-1; } else{ labels[node] = mn; mn++; } for(auto &x: g[node]){ if(x == p) continue; calc_labels(x,node,t^1); } } std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) { sub_tree.assign(n,0); g.resize(n); for(int i = 0; i<n-1; i++){ g[u[i]].pb(v[i]); g[v[i]].pb(u[i]); } dfs(0,-1); mn = 1; calc_labels(0,-1,1); return labels; } int find_next_station(int s, int t, std::vector<int> c) { if(c[0]>s){ int l = s; for(int i = 0; i<c.size()-1; i++){ if(t>=l and t<=c[i]){ return c[i]; } else l = c[i]+1; } return c.back(); } else{ int r = s; for(int i = c.size()-1; i; i--){ if(t>=c[i] and t<=r) return c[i]; else r = c[i]-1; } return c[0]; } }

Compilation message (stderr)

stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:53:11: error: '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'class std::vector<int>'} has no member named 'pb'
   53 |   g[u[i]].pb(v[i]);
      |           ^~
stations.cpp:54:11: error: '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'class std::vector<int>'} has no member named 'pb'
   54 |   g[v[i]].pb(u[i]);
      |           ^~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:70:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   70 |   for(int i = 0; i<c.size()-1; i++){
      |                  ~^~~~~~~~~~~