제출 #828266

#제출 시각아이디문제언어결과실행 시간메모리
828266tomruk기지국 (IOI20_stations)C++17
0 / 100
659 ms652 KiB
#include "stations.h" #include <bits/stdc++.h> #define N 1005 using namespace std; int tin[N],tout[N]; int d[N]; vector<int> adj[N]; int timer = 0; void dfs(int v,int par){ tin[v] = timer++; for(auto u:adj[v]){ if(u == par) continue; d[u] = d[v] + 1; dfs(u,v); } tout[v] = timer++; } vector<int> label(int n, int k, vector<int> u, vector<int> v) { for(int i = 0;i<n;i++){ adj[i].clear(); } for(int i = 0;i<n-1;i++){ adj[u[i]].push_back(v[i]); adj[v[i]].push_back(u[i]); } dfs(0,-1); vector<int> ret(n,0); for(int i = 0;i<n;i++){ if(d[i] & 1) ret[i] = tin[i]; else ret[i] = tout[i]; } return ret; } int find_next_station(int s, int t, vector<int> c){ if(c.size() == 1) return c[0]; if(c[0] > s){ int l = s; int r = c[c.size()-2]; if(t < l || t > r) return c.back(); int x = 1e9; for(int i = 0;i<c.size()-1;i++){ if(c[i] >= t) x = min(x,c[i]); } return x; } else{ int l = c[1]; int r = s; if(t < l || t > r) return c.back(); int x = 0; for(int i = 1;i<c.size();i++){ if(c[i] <= t) x = max(x,c[i]); } return x; } }

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

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:46:18: 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++){
      |                 ~^~~~~~~~~~~
stations.cpp:58:18: 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 = 1;i<c.size();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...