제출 #934102

#제출 시각아이디문제언어결과실행 시간메모리
934102EJIC_B_KEDAX기지국 (IOI20_stations)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using ll = long long; using namespace std; vector<vector<int>> g; vector<int> res; void dfs(int s, int p = -1, int d = 0) { if (~d & 1) { res.push_back(s); } for (int i : g[s]) { if (i != p) { dfs(i, s, d + 1); } } if (d & 1) { res.push_back(s); } } vector<int> label(int n, int k, vector<int> u, vector<int> v) { g.resize(n); for (int i = 0; i < n; i++) { g[i].clear(); } res.clear(); for (int i = 0; i < n - 1; i++) { g[u[i]].push_back(v[i]); g[v[i]].push_back(u[i]); } dfs(0); return res; } int find_next_station(int s, int t, vector<int> c) { if (c[0] > n) { if (t < s) { return c.back(); } for (int i = 0; i < c.size(); i++) { if (c[i] >= t) { return c[i]; } } return c.back(); } else { if (t > s) { return c[0]; } for (int i = c.size() - 1; i >= 0; i--) { if (c[i] <= t) { return c[i]; } } return c[0]; } }

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

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:39:16: error: 'n' was not declared in this scope
   39 |     if (c[0] > n) {
      |                ^
stations.cpp:43:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |         for (int i = 0; i < c.size(); i++) {
      |                         ~~^~~~~~~~~~
stations.cpp:60:1: warning: control reaches end of non-void function [-Wreturn-type]
   60 | }
      | ^