제출 #433047

#제출 시각아이디문제언어결과실행 시간메모리
433047peuch기지국 (IOI20_stations)C++17
100 / 100
899 ms756 KiB
#include "stations.h" #include <bits/stdc++.h> using namespace std; int cnt; vector<vector<int> > ar; vector<int> ord; vector<int> lbl; void dfs(int cur, int pai, int prof){ if(prof % 2 == 0) ord.push_back(cur); for(int i = 0; i < ar[cur].size(); i++){ int viz = ar[cur][i]; if(viz == pai) continue; dfs(viz, cur, prof + 1); } if(prof % 2 == 1) ord.push_back(cur); } vector<int> label(int n, int k, vector<int> u, vector<int> v) { ar = vector<vector<int> > (n); lbl = vector<int> (n); ord.clear(); for(int i = 0; i < u.size(); i++){ ar[u[i]].push_back(v[i]); ar[v[i]].push_back(u[i]); } dfs(0, 0, 0); assert(ord.size() == n); for(int i = 0; i < n; i++) lbl[ord[i]] = i; return lbl; } int find_next_station(int s, int t, std::vector<int> c) { if(t == s) return s; if(c.size() == 1) return c[0]; if(s < c[0]){ if(t < s) return c.back(); for(int i = 0; i < c.size(); i++) if(t <= c[i]) return c[i]; return c.back(); } else{ if(t > s) return c[0]; for(int i = c.size() - 1; i >= 0; i--) if(t >= c[i]) return c[i]; return c[0]; } }

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

stations.cpp: In function 'void dfs(int, int, int)':
stations.cpp:12:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |  for(int i = 0; i < ar[cur].size(); i++){
      |                 ~~^~~~~~~~~~~~~~~~
stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:24:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |  for(int i = 0; i < u.size(); i++){
      |                 ~~^~~~~~~~~~
In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from stations.cpp:2:
stations.cpp:29:20: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   29 |  assert(ord.size() == n);
      |         ~~~~~~~~~~~^~~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:40:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |   for(int i = 0; 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...