제출 #660165

#제출 시각아이디문제언어결과실행 시간메모리
660165evenvalue기지국 (IOI20_stations)C++17
0 / 100
768 ms656 KiB
#include "stations.h" #include <bits/stdc++.h> using namespace std; template<typename T> using min_heap = priority_queue<T, vector<T>, greater<T>>; template<typename T> using max_heap = priority_queue<T, vector<T>, less<T>>; using int64 = long long; using ld = long double; constexpr int kInf = 1e9 + 10; constexpr int64 kInf64 = 1e15 + 10; constexpr int kMod = 1e9 + 7; 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> depth(n); vector<int> tin(n, -1), tout(n, -1); function<int(int, int)> dfs = [&](int x, int p)-> int { int time = tin[x] + 1; for (const int y : g[x]) { if (y == p) continue; tin[y] = time; depth[y] = 1 - depth[x]; time = dfs(y, x) + 1; } return tout[x] = time; }; depth[0] = 0; tin[0] = tout[0] = 0; dfs(0, -1); vector<int> labels(n); for (int x = 0; x < n; x++) { labels[x] = (depth[x] == 0 ? tin[x] : tout[x]); } return labels; } int find_next_station(int s, int t, vector<int> c) { if (c[0] > s) { sort(c.begin(), c.end()); for (int i = 0; i < c.size() - 1; i++) { if (s < t and t <= c[i]) return c[i]; } return c.back(); } else { sort(c.begin(), c.end()); for (int i = 0; i < c.size() - 1; i++) { if (c[i] <= t and s < t) return c[i]; } return c.back(); } }

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

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:52:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |     for (int i = 0; i < c.size() - 1; i++) {
      |                     ~~^~~~~~~~~~~~~~
stations.cpp:58:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |     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...