Submission #592297

#TimeUsernameProblemLanguageResultExecution timeMemory
592297Soumya1Stations (IOI20_stations)C++17
100 / 100
929 ms780 KiB
#include "stations.h" #include <bits/stdc++.h> using namespace std; const int mxN = 1005; vector<int> ad[mxN]; int val[mxN]; int timer; void dfs(int u, int p, int d = 0) { if (d) val[u] = timer++; for (int v : ad[u]) { if (v == p) continue; dfs(v, u, d ^ 1); } if (!d) val[u] = timer++; } vector<int> label(int n, int k, vector<int> u, vector<int> v) { timer = 0; for (int i = 0; i < n; i++) { ad[i].clear(); } for (int i = 0; i < n - 1; i++) { ad[u[i]].push_back(v[i]); ad[v[i]].push_back(u[i]); } dfs(0, -1); vector<int> ret(n); for (int i = 0; i < n; i++) { ret[i] = val[i]; } return ret; } int find_next_station(int s, int t, vector<int> c) { if (s > c.back()) { if (t > s) return c[0]; for (int i = c.size() - 1; i >= 1; i--) { if (t >= c[i]) return c[i]; } return c[0]; } else { if (t < s) return c.back(); for (int i = 0; i < c.size() - 1; i++) { if (t <= c[i]) return c[i]; } return c.back(); } }

Compilation message (stderr)

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