제출 #956419

#제출 시각아이디문제언어결과실행 시간메모리
956419Desh03기지국 (IOI20_stations)C++17
76 / 100
614 ms1548 KiB
#include <bits/stdc++.h> using namespace std; vector<int> label(int n, int k, vector<int> u, vector<int> v) { vector<vector<int>> g(n); for (int i = 0; i < n - 1; i++) { g[u[i]].push_back(v[i]); g[v[i]].push_back(u[i]); } vector<int> in(n), en(n), d(n); int t = 0; auto dfs = [&](const auto &self, int u) -> void { in[u] = t++; for (int v : g[u]) { g[v].erase(find(g[v].begin(), g[v].end(), u)); d[v] = d[u] + 1; self(self, v); } en[u] = t++; }; dfs(dfs, 0); vector<int> id(n); for (int i = 0; i < n; i++) { if (d[i] % 2 == 0) { id[i] = in[i]; } else { id[i] = en[i]; } } return id; } int find_next_station(int s, int t, vector<int> c) { if (c[0] > s) { int in = s + 1; for (int i = 0; i < c.size() - 1; i++) { if (in <= t && t <= c[i]) { return c[i]; } in = c[i] + 1; } return c.back(); } else { int en = s; for (int i = c.size() - 1; i > 0; i--) { if (c[i] <= t && t <= en) { return c[i]; } en = c[i] - 1; } return c[0]; } }

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

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:37:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |         for (int i = 0; i < c.size() - 1; i++) {
      |                         ~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...