제출 #851674

#제출 시각아이디문제언어결과실행 시간메모리
851674yellowtoad기지국 (IOI20_stations)C++17
0 / 100
574 ms1072 KiB
#include "stations.h" #include <iostream> #include <vector> #include <algorithm> using namespace std; vector<int> path, edge[1010]; void dfs(int u, int v, int d) { if (d%2 == 0) path.push_back(u); for (int i = 0; i < edge[u].size(); i++) if (edge[u][i] != v) dfs(edge[u][i],u,d+1); if (d%2) path.push_back(u); } std::vector<int> label(int n, int _, std::vector<int> u, std::vector<int> v) { path.clear(); vector<int> labels(n); for (int i = 0; i < n; i++) edge[i].clear(); for (int i = 0; i < n-1; i++) { edge[u[i]].push_back(v[i]); edge[v[i]].push_back(u[i]); } dfs(0,-1,0); for (int i = 0; i < n; i++) labels[path[i]] = i; return labels; } int find_next_station(int s, int t, std::vector<int> c) { if (c[0] > s) { if (t < s) return c[c.size()-1]; for (int i = 0; i < c.size()-1; i++) if (t <= c[i]) return c[i]; return c[c.size()-1]; } else { for (int i = 1; i < c.size()-1; i++) if (t < c[i]) return c[i-1]; if (t < s) c[c.size()-2]; return c[c.size()-1]; } }

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

stations.cpp: In function 'void dfs(int, int, int)':
stations.cpp:11:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |  for (int i = 0; i < edge[u].size(); i++) if (edge[u][i] != v) dfs(edge[u][i],u,d+1);
      |                  ~~^~~~~~~~~~~~~~~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:31:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |   for (int i = 0; i < c.size()-1; i++) if (t <= c[i]) return c[i];
      |                   ~~^~~~~~~~~~~~
stations.cpp:34:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |   for (int i = 1; i < c.size()-1; i++) if (t < c[i]) return c[i-1];
      |                   ~~^~~~~~~~~~~~
#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...