제출 #442403

#제출 시각아이디문제언어결과실행 시간메모리
442403DmitryGrigorev기지국 (IOI20_stations)C++14
100 / 100
1035 ms860 KiB
#include <bits/stdc++.h> #define ll long long #define db long double #define x first #define y second #define mp make_pair #define pb push_back #define all(a) a.begin(), a.end() using namespace std; const int mod = 1000000007; void add(int& a, int b) { a += b; if (a >= mod) a -= mod; if (a < 0) a += mod; } int mult(int a, int b) { return a * (ll)b % mod; } int bp(int a, int b) { int res = 1; while (b > 0) { if (b & 1) res = mult(res, a); a = mult(a, a); b >>= 1; } return res; } vector<vector<int> > gr; vector<int> ans; int timer; void dfs(int vertex, int last, int d) { if (d%2==0) ans[vertex] = timer++; for (auto to : gr[vertex]) { if (to==last) continue; dfs(to, vertex, d+1); } if (d%2!=0) ans[vertex] = timer++; } vector<int> label(int n, int k, vector<int> u, vector<int> v) { gr.assign(n, {}); timer = 0; for (int i = 0; i < n-1; ++i) { gr[u[i]].pb(v[i]); gr[v[i]].pb(u[i]); } ans.assign(n, -1); dfs(0, -1, 0); return ans; } int find_next_station(int s, int t, vector<int> c) { if (s < c[0]) { int last = s; for (int i = 0; i + 1 < c.size(); ++i) { auto x = c[i]; if (t > last && t <= x) return x; last = x; } return c.back(); } else { int last = s; for (int i = c.size() - 1; i >= 0; --i) { auto x = c[i]; if (t >= x && t < last) return x; last = x; } return c[0]; } } #ifdef LOCAL int main(){ freopen("D_input.txt", "r", stdin); //freopen("D_output.txt", "w", stdout); ios_base::sync_with_stdio(0); cin.tie(0); } #endif

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

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