제출 #921478

#제출 시각아이디문제언어결과실행 시간메모리
921478ksujay2기지국 (IOI20_stations)C++17
0 / 100
1 ms600 KiB
#include <bits/stdc++.h> using namespace std; vector<int> label(int n, int k, vector<int> u, vector<int> v) { vector<vector<int>> adj(n); for(int i = 0; i < n - 1; i++) { adj[u[i] - 1].push_back(v[i] - 1); adj[v[i] - 1].push_back(u[i] - 1); } int t = 0; vector<int> label(n); function<void(int, int, int)> dfs = [&] (int s, int e, int p) { if(!p) label[s] = t++; for(int u : adj[s]) { if(u != e) { dfs(u, s, p ^ 1); } } if(p) label[s] = t++; }; dfs(0, -1, 0); return label; } int find_next_station(int s, int t, vector<int> c) { bool mn = true; for(int u : c) { if(u < s) { mn = false; } } if(mn) { int p = c.back(); if(s <= t && t <= p - 1) { int prev = s + 1; for(int i = 0; i < c.size() - 1; i++) { if(prev <= t && t <= c[i]) { return c[i]; } prev = c[i] + 1; } assert(true); } else { return p; } } else { int p = c[0]; if(p + 1 <= t && t <= s) { int prev = s - 1; for(int i = c.size() - 1; i > 0; i--) { if(c[i] <= t && t <= prev) { return c[i]; } prev = c[i] + 1; } assert(true); } else { return p; } } }

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

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:36:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |             for(int i = 0; i < c.size() - 1; i++) {
      |                            ~~^~~~~~~~~~~~~~
stations.cpp:61:1: warning: control reaches end of non-void function [-Wreturn-type]
   61 | }
      | ^
#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...