제출 #602087

#제출 시각아이디문제언어결과실행 시간메모리
602087Morisz10기지국 (IOI20_stations)C++14
0 / 100
3051 ms2097152 KiB
#include "stations.h" #include <vector> #include <algorithm> #include <iostream> #include <cassert> #include <map> #include <cstdio> using namespace std; const int maxn = 1010; vector<int> g[maxn]; vector<int> lab, siz; int calc_siz(int x, int p) { for (int i : g[x]) { if (i == p)continue; siz[x] += calc_siz(i, x); } return siz[x]; } void calc_lab(int x, int p) { int sum = 0, pl = (p < 0 ? maxn : lab[p]); for (int i : g[x]) { if (i == p)continue; if (pl > lab[x]) { lab[i] = lab[x] + siz[i] + sum; } else { lab[i] = lab[x] - siz[i] - sum; } calc_lab(i, x); sum += siz[i]; } return; } vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) { lab.assign(n, 0); siz.assign(n, 1); for (int i = 0; i < u.size(); i++) { g[u[i]].push_back(v[i]); g[v[i]].push_back(u[i]); } calc_siz(0, -1); calc_lab(0, -1); return lab; } int find_next_station(int s, int t, std::vector<int> c) { if (s > c[0]) { reverse(c.begin(), c.end()); for (int i : c) { if (s > t && t >= i)return i; } return c.back(); } else { for (int i : c) { if (s < t && t <= i)return i; } return c.back(); } }

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

stations.cpp: In function 'std::vector<int> label(int, int, std::vector<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 < u.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...