Submission #307065

#TimeUsernameProblemLanguageResultExecution timeMemory
307065junseoStations (IOI20_stations)C++17
0 / 100
901 ms1024 KiB
#include "stations.h" #include <bits/stdc++.h> #define fi first #define se second #define eb emplace_back #define all(v) (v).begin(), (v).end() #define rmin(r, x) r = min(r, x) #define rmax(r, x) r = max(r, x) #define ends ' ' #define endl '\n' #define fastio ios_base::sync_with_stdio(0), cin.tie(0) using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int maxn = 1e3 + 10; int T; vector<int> l, adj[maxn]; void dfs(int u, int p, bool f) { if(f) l[u] = T++; for(auto& v : adj[u]) if(v != p) dfs(v, u, f ^ true); if(!f) l[u] = T++; } vector<int> label(int n, int k, vector<int> u, vector<int> v) { T = 0; l.resize(n); for(int i = 0; i < n; ++i) adj[i].clear(); for(int i = 0; i < u.size(); ++i) { adj[u[i]].eb(v[i]); adj[v[i]].eb(u[i]); } dfs(0, -1, true); return l; } int find_next_station(int s, int t, vector<int> c) { int n = c.size(); if(n == 1) return c[0]; if(s < c[0]) { if(!s && (t < s || c[n - 2] < t)) return c[n - 1]; for(int i = 0; i < n; ++i) if(t <= c[i]) return c[i]; } else { if(t < c[1] || s < t) return c[0]; for(int i = n - 1; i >= 0; --i) if(c[i] <= t) return c[i]; } }

Compilation message (stderr)

stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:32:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |  for(int i = 0; i < u.size(); ++i) {
      |                 ~~^~~~~~~~~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:51:1: warning: control reaches end of non-void function [-Wreturn-type]
   51 | }
      | ^
#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...