제출 #591642

#제출 시각아이디문제언어결과실행 시간메모리
591642Morisz10기지국 (IOI20_stations)C++14
컴파일 에러
0 ms0 KiB
#include "stations.h" #include <vector> #include <algorithm> #include <iostream> using namespace std; const int maxn = 1000; vector<int> g[maxn]; int l; vector<int> labels, max_label, r_label; int dfs(int x, int p) { max_label[x] = labels[x] = l++; r_label[labels[x]] = x; for (int i : g[x]) { if (i != p)max_label[x] = dfs(i, x); } return max_label[x]; } vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) { labels.assign(n, 0); for (int i = 0; i < n; i++)g[i] = {}; max_label = labels; r_label = labels; for (int i = 0; i < u.size(); i++) { g[u[i]].push_back(v[i]); g[v[i]].push_back(u[i]); } l = 0; dfs(0, -1); return labels; } int find_next_station(int s, int t, std::vector<int> c) { for (int i = 0; i < c.size() - 1; i++) { if (t < c[i + 1])return c[i]; } return t > max_label[r_label[c.back()]] ? c[0] : c.back(); } int main() { int n, k; cin >> n >> k; vector<int> u(n - 1), v(n - 1); for (int i = 0; i < n - 1; i++) { cin >> u[i] >> v[i]; } label(n, k, u, v); }

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

stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:24:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |  for (int i = 0; i < u.size(); i++) {
      |                  ~~^~~~~~~~~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:34:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |  for (int i = 0; i < c.size() - 1; i++) {
      |                  ~~^~~~~~~~~~~~~~
/usr/bin/ld: /tmp/cckMqeUH.o: in function `main':
stub.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccHBJNsK.o:stations.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status