Submission #462518

#TimeUsernameProblemLanguageResultExecution timeMemory
462518wind_reaperStations (IOI20_stations)C++17
Compilation error
0 ms0 KiB
#include "stations.h" #include <bits/stdc++.h> using namespace std; vector<int> g[1000]; int timer; void dfs(vector<int>& tin, int u, int p, int& timer, int d){ if(!d) tin[u] = timer++; for(int v : g[u]) if(v != p){ dfs(tin, v, u, 1 - d); } if(d) tin[u] = timer++; } vector<int> label(int n, int k, int u, int v){ for(int i = 0; i < n - 1; i++){ g[u[i]].push_back(v[i]); g[v[i]].push_back(u[i]); } vector<int> tin(n); dfs(g, tin, 0, -1, 0, 0); return tin; } int find_next_station(int s, int t, vector<int> c){ int m = cc.size(), i; if(s < c[0]){ for(i = 0; i < m - 1; i++) if(i == 0 ? s : c[i-1] < t && c[i] >= t) break; } else{ for(int i = m - 1; i > 0; --i) if(i + 1 == m ? s : c[i+1] > t && c[i] <= t) break; } return c[i]; }

Compilation message (stderr)

stations.cpp: In function 'void dfs(std::vector<int>&, int, int, int&, int)':
stations.cpp:12:20: error: cannot bind non-const lvalue reference of type 'int&' to an rvalue of type 'int'
   12 |   dfs(tin, v, u, 1 - d);
      |                  ~~^~~
stations.cpp:9:47: note: in passing argument 4 of 'void dfs(std::vector<int>&, int, int, int&, int)'
    9 | void dfs(vector<int>& tin, int u, int p, int& timer, int d){
      |                                          ~~~~~^~~~~
stations.cpp: In function 'std::vector<int> label(int, int, int, int)':
stations.cpp:19:6: error: invalid types 'int[int]' for array subscript
   19 |   g[u[i]].push_back(v[i]);
      |      ^
stations.cpp:19:22: error: invalid types 'int[int]' for array subscript
   19 |   g[u[i]].push_back(v[i]);
      |                      ^
stations.cpp:20:6: error: invalid types 'int[int]' for array subscript
   20 |   g[v[i]].push_back(u[i]);
      |      ^
stations.cpp:20:22: error: invalid types 'int[int]' for array subscript
   20 |   g[v[i]].push_back(u[i]);
      |                      ^
stations.cpp:24:6: error: invalid initialization of reference of type 'std::vector<int>&' from expression of type 'std::vector<int> [1000]'
   24 |  dfs(g, tin, 0, -1, 0, 0);
      |      ^
stations.cpp:9:23: note: in passing argument 1 of 'void dfs(std::vector<int>&, int, int, int&, int)'
    9 | void dfs(vector<int>& tin, int u, int p, int& timer, int d){
      |          ~~~~~~~~~~~~~^~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:30:10: error: 'cc' was not declared in this scope; did you mean 'c'?
   30 |  int m = cc.size(), i;
      |          ^~
      |          c
stations.cpp:32:7: error: 'i' was not declared in this scope
   32 |   for(i = 0; i < m - 1; i++)
      |       ^
stations.cpp:42:11: error: 'i' was not declared in this scope
   42 |  return c[i];
      |           ^