제출 #398254

#제출 시각아이디문제언어결과실행 시간메모리
398254Everule기지국 (IOI20_stations)C++17
76 / 100
1162 ms788 KiB
//#include "stations.h" #include <bits/stdc++.h> using namespace std; std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) { std::vector<int> labels(n); 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> tin(n), tout(n), dep(n); int t = 0; function<void(int,int)> dfs = [&](int u,int p){ tin[u] = t++; for(auto &v : adj[u]){ if(v == p) continue; dep[v] = dep[u] + 1; dfs(v, u); } tout[u] = t++; }; dfs(0, 0); for(int i=0;i<n;i++){ if(dep[i] % 2 == 0){ labels[i] = tin[i]; } else{ labels[i] = tout[i]; } } return labels; } int find_next_station(int s, int t, std::vector<int> c) { if(c.size() == 1) return c[0]; sort(c.begin(), c.end()); if(c[0] < s){ if(t < c[1] || t > s){ return c[0]; } for(int i=c.size()-1;i>0;--i){ if(c[i] <= t) return c[i]; } } else{ reverse(c.begin(), c.end()); if(t > c[1] || t < s){ return c[0]; } for(int i=c.size()-1;i>0;--i){ if(c[i] >= t) return c[i]; } } }

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

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