Submission #979306

#TimeUsernameProblemLanguageResultExecution timeMemory
979306ZicrusStations (IOI20_stations)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "stations.h" using namespace std; vector<int> lbl; vector<vector<int>> adj; void DFS(int index, int last, int id) { lbl[index] = id; for (auto node : adj[index]) { if (node == last) continue; DFS(node, index, id + 1); } } vector<int> label(int N, int K, vector<int> U, vector<int> V) { adj = vector<vector<int>>(n); lbl = vector<int>(n); for (int i = 0; i < N - 1; i++) { adj[U[i]].push_back(V[i]); adj[V[i]].push_back(U[i]); } for (int i = 0; i < N; i++) { if (adj[i].size() == 1) { DFS(i, -1, 0); break; } } return lbl; } int find_next_station(int S, int T, vector<int> C) { if (T > S) { return S + 1; } return S - 1; }

Compilation message (stderr)

stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:20:31: error: 'n' was not declared in this scope
   20 |     adj = vector<vector<int>>(n);
      |                               ^