제출 #594544

#제출 시각아이디문제언어결과실행 시간메모리
594544snasibov05기지국 (IOI20_stations)C++14
76 / 100
982 ms764 KiB
#include "stations.h" #include <bits/stdc++.h> using namespace std; int tmm = 0; void dfs(int cur, int pr, vector<int>& tin, vector<int>& tout, vector<int>& d, vector<vector<int>>& ed) { tin[cur] = tmm++; d[cur] = d[pr] + 1; for (auto to : ed[cur]) { if (to == pr) continue; dfs(to, cur, tin, tout, d, ed); } tout[cur] = tmm++; } vector<int> label(int n, int k, vector<int> u, vector<int> v) { vector<vector<int>> ed(n); for (int i = 0; i < n-1; ++i) { ed[u[i]].push_back(v[i]); ed[v[i]].push_back(u[i]); } vector<int> d(n), tin(n), tout(n); tmm = 0, d[0] = -1; dfs(0, 0, tin, tout, d, ed); vector<int> label(n); for (int i = 0; i < n; ++i){ if (d[i] % 2 == 0) label[i] = tin[i]; else label[i] = tout[i]; } return label; } int find_next_station(int s, int t, vector<int> c) { sort(c.begin(), c.end()); if (s < c[0]){ int prev = s; for (int i = 0; i < c.size() - 1; ++i){ if (prev <= t && t <= c[i]) return c[i]; prev = c[i]; } return c.back(); } else{ int prev = s; for (int i = c.size() - 1; i > 0; --i){ if (c[i] <= t && t <= prev) return c[i]; prev = c[i]; } return c[0]; } }

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

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:46:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |         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...