Submission #934104

#TimeUsernameProblemLanguageResultExecution timeMemory
934104EJIC_B_KEDAXStations (IOI20_stations)C++17
0 / 100
538 ms1124 KiB
#include <bits/stdc++.h> using ll = long long; using namespace std; vector<vector<int>> g; vector<int> res; void dfs(int s, int p = -1, int d = 0) { if (~d & 1) { res.push_back(s); } for (int i : g[s]) { if (i != p) { dfs(i, s, d + 1); } } if (d & 1) { res.push_back(s); } } vector<int> label(int n, int k, vector<int> u, vector<int> v) { g.resize(n); for (int i = 0; i < n; i++) { g[i].clear(); } res.clear(); for (int i = 0; i < n - 1; i++) { g[u[i]].push_back(v[i]); g[v[i]].push_back(u[i]); } dfs(0); return res; } int find_next_station(int s, int t, vector<int> c) { if (c[0] > s) { if (t < s) { return c.back(); } for (int i = 0; i < c.size(); i++) { if (c[i] >= t) { return c[i]; } } return c.back(); } else { if (t > s) { return c[0]; } for (int i = c.size() - 1; i >= 0; i--) { if (c[i] <= t) { return c[i]; } } return c[0]; } }

Compilation message (stderr)

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