Submission #744667

#TimeUsernameProblemLanguageResultExecution timeMemory
744667GusterGoose27Stations (IOI20_stations)C++17
0 / 100
1949 ms2097152 KiB
#include "stations.h" #include <bits/stdc++.h> using namespace std; const int MAXN = 1000; vector<int> edges[MAXN]; int t = 0; void dfs(int cur, bool par, int p, vector<int> &ans) { if (par) ans[cur] = t++; for (int nxt: edges[cur]) { if (nxt == p) continue; dfs(nxt, !par, cur, ans); } if (!par) ans[cur] = t++; } vector<int> label(int n, int k, vector<int> u, vector<int> v) { vector<int> ans(n); for (int i = 0; i < n-1; i++) { edges[u[i]].push_back(v[i]); edges[v[i]].push_back(u[i]); } dfs(0, 1, -1, ans); return ans; } int find_next_station(int s, int t, vector<int> c) { return 0; if (c.size() == 1) return c[0]; if (s == 0) { for (int i = 0; i < c.size(); i++) if (c[i] >= t) return c[i]; } vector<int> vals; // left inclusive, right exclusive if (s < c[0]) { int l = s; int r = c[c.size()-2]; if (t > r || t < l) return c.back(); for (int i: c) { if (i >= t) return i; } } int l = c[1]; int r = s; if (t < l || t > r) return c[0]; for (int i = c.size()-1; i > 0; i--) if (c[i] <= t) return c[i]; return 0; assert(false); }

Compilation message (stderr)

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