제출 #772528

#제출 시각아이디문제언어결과실행 시간메모리
772528SanguineChameleon기지국 (IOI20_stations)C++17
컴파일 에러
0 ms0 KiB
#include "stations.h" #include <bits/stdc++.h> using namespace std; const int maxn = 1e3 + 20; vector<int> adj[maxn]; int tin[maxn]; int tout[maxn]; int depth[maxn]; int dfs_t; void dfs(int u, int p) { tin[u] = ++dfs_t; for (auto v: adj[u]) { if (v != p) { depth[v] = depth[u] + 1; dfs(v, u); } } tout[u] = ++dfs_t; } vector<int> label(int n, int k, vector<int> u, vector<int> v) { for (int i = 0; i < n; i++) { adj[i].clear(); } for (int i = 0; i < n - 1; i++) { adj[u[i]].push_back(v[i]); adj[v[i]].push_back(u[i]); } dfs_t = -1; dfs(0, -1); vector<pair<int, int>> order(n); for (int i = 0; i < n; i++) { order[i] = make_pair(depth[i] & 1 ? tout[i] : tin[i], i); } sort(order[i].begin(), order[i].end()); vector<int> labels(n); for (int i = 0; i < n; i++) { labels[order[i].second] = i; } return labels; } int find_next_station(int s, int t, vector<int> c) { sort(c.begin(), c.end()); if (s < c[0]) { for (int i = 0; i < (int)c.size() - 1; i++) { if ((i ? c[i - 1] : s) < t && t <= c[i]) { return c[i]; } } return c.back(); } else { for (int i = 1; i < (int)c.size(); i++) { if (c[i] <= t && t < (i < (int)c.size() - 1 ? c[i + 1] : s)) { return c[i]; } } return c[0]; } }

컴파일 시 표준 에러 (stderr) 메시지

stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:37:13: error: 'i' was not declared in this scope
   37 |  sort(order[i].begin(), order[i].end());
      |             ^