제출 #1052364

#제출 시각아이디문제언어결과실행 시간메모리
1052364fuad27기지국 (IOI20_stations)C++17
0 / 100
493 ms692 KiB
#include "stations.h" #include <bits/stdc++.h> using namespace std; const int N = 1010; vector<int> g[N]; int tin[N], tout[N], dp[N]; int tim=0, tim2=0; void dfs(int at, int p) { // if(dp[at]) tin[at]=tim++; for(int to:g[at]) { if(to==p)continue; dp[to] = dp[at]^1; dfs(to, at); } // if(!dp[at]) tout[at]=tim++; } 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++)g[i].clear(); tim=0; for(int i = 0;i<n-1;i++) { g[u[i]].push_back(v[i]); g[v[i]].push_back(u[i]); } dfs(0,0); for (int i = 0; i < n; i++) { if(dp[i])labels[i] = tin[i]; else labels[i] = tout[i]; // cout << i << " " << labels[i] << endl; } return labels; } int find_next_station(int s, int t, std::vector<int> c) { vector<int> kk = c; if(c.size()==1)return c[0]; sort(kk.begin(), kk.end()); if(kk[0] >= s) { for(int i = 0;i<kk.size();i++) { if(kk[i] >= t)return kk[i]; } return kk.back(); } else if(kk.back() <= s) { for(int i = kk.size()-1;i>=0;i--) { if(kk[i] <= t) { return kk[i]; } } return kk[0]; } return 0; }

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

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:42:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |   for(int i = 0;i<kk.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...