Submission #605700

#TimeUsernameProblemLanguageResultExecution timeMemory
605700MohamedAliSaidaneStations (IOI20_stations)C++14
76 / 100
1101 ms852 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; typedef vector<int> vi; typedef vector<ll> vll; typedef vector<pii> vpi; typedef vector<pll> vpl; #define pb push_back #define popb pop_back #define all(x) (x).begin(),(x).end() #define ff first #define ss second const int nax = 1001; vi rep; int cureul = -1; vi adj[nax]; int in[nax], out[nax]; void dfs(int x, int d = 0, int p = -1) { in[x] = cureul++; for(auto e: adj[x]) if(e != p) dfs(e, d + 1, x); out[x] = cureul++; if(d & 1) rep[x] = out[x]; else rep[x] = in[x]; } vi label(int n, int k, vi u, vi v) { for(int i = 0 ; i < n; i++) adj[i].clear(); cureul = 0; rep.assign(n , 0); for(int i= 0; i < n - 1; i ++) { adj[u[i]].pb(v[i]); adj[v[i]].pb(u[i]); } dfs(0); return rep; } int find_next_station(int s, int t, vi c) { sort(all(c)); int sz = c.size(); bool ev = s < c[0]; int ini, outi; if(ev) { ini = s; if(s == 0) outi = 1999; else if(sz == 1) outi = ini + 1; else outi = c[sz - 2] + 1; if(t >= ini && t <= outi) { for(auto e: c) if(e >= t) return e; } else { return c[sz - 1]; } } else { outi = s; if(sz == 1) ini = outi; else ini = c[1] - 1; if(t >= ini && t <= outi) { reverse(all(c)); for(auto e: c) if(e <= t) return e; } else { return c[0]; } } }

Compilation message (stderr)

stations.cpp: In function 'int find_next_station(int, int, vi)':
stations.cpp:100:5: warning: control reaches end of non-void function [-Wreturn-type]
  100 |     }
      |     ^
#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...