제출 #838285

#제출 시각아이디문제언어결과실행 시간메모리
838285puppy기지국 (IOI20_stations)C++17
0 / 100
572 ms932 KiB
#include "stations.h" #include <vector> #include <functional> #include <algorithm> #include <iostream> using namespace std; std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) { vector<vector<int>> adj(n); for (int i = 0; i < n-1; i++) { adj[u[i]].push_back(v[i]); adj[v[i]].push_back(u[i]); } vector<int> id(n); int ord = 0; function<void(int, int, int)> dfs = [&](int v, int p, int depth) { if (depth % 2 == 0) id[v] = ord++; for (int i:adj[v]) { if (i != p) dfs(i, v, depth + 1); } if (depth % 2 == 1) id[v] = ord++; }; dfs(0, -1, 0); return id; } int find_next_station(int s, int t, std::vector<int> c) { int parity = -1; if (c[0] > s) parity = 0; else parity = 1; sort(c.begin(), c.end()); if (s) { if (parity == 0) { if (t < s || c[c.size()-2] < t) return c.back(); } else { if (t < c[1] || s < t) return c[0]; } } if (parity == 0) { for (int i = 0; i < (int)c.size(); i++) { if (t <= c[i]) return c[i]; } } else { for (int i = (int)c.size() - 1; i >= 0; i--) { if (t >= c[i]) return c[i]; } } }

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

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:51:1: warning: control reaches end of non-void function [-Wreturn-type]
   51 | }
      | ^
#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...