제출 #697063

#제출 시각아이디문제언어결과실행 시간메모리
697063garam1732기지국 (IOI20_stations)C++14
76 / 100
884 ms904 KiB
#include "stations.h" #include <bits/stdc++.h> using namespace std; vector<int> adj[1010]; int in[1010], out[1010], cnt; void dfs(int here, int par, bool flag, vector<int>& labels) { in[here] = cnt++; for(int there : adj[here]) { if(there == par) continue; dfs(there, here, !flag, labels); } out[here] = cnt++; labels[here] = (flag ? in[here] : out[here]); } std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) { std::vector<int> labels(n); for(int i = 0; i < n; i++) adj[i].clear(); cnt = 0; for(int i = 0; i < u.size(); i++) { adj[u[i]].push_back(v[i]); adj[v[i]].push_back(u[i]); } dfs(0, 0, 0, labels); return labels; } int find_next_station(int s, int t, std::vector<int> c) { if(s < c[0]) { if(s < t && t <= c[0]) return c[0]; for(int i = 1; i < c.size(); i++) if(c[i-1] < t && t <= c[i]) return c[i]; return *c.rbegin(); } for(int i = 2; i < c.size(); i++) if(c[i-1] <= t && t < c[i]) return c[i-1]; if(*c.rbegin() <= t && t < s) return *c.rbegin(); return c[0]; }

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

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++) {
      |                 ~~^~~~~~~~~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:36:26: 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 = 1; i < c.size(); i++) if(c[i-1] < t && t <= c[i]) return c[i];
      |                        ~~^~~~~~~~~~
stations.cpp:40:19: 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 = 2; i < c.size(); i++) if(c[i-1] <= t && 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...