Submission #605691

#TimeUsernameProblemLanguageResultExecution timeMemory
605691MohamedAliSaidaneStations (IOI20_stations)C++14
0 / 100
824 ms528 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 = -1; 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 ini, outi; int sz = c.size(); bool flag= true; if(s < c[0]) { ini = s; if(ini == 0) { outi = 1000; } else if(sz == 1) outi = ini; else outi = c[sz - 2]; } else { flag = false; outi = s; if(sz == 1) ini = outi; else ini = c[1] - 1; } if(t >= ini && t <= outi) { for(auto e: c) { if(flag) { for(auto e: c) if(e >= t) return e; } else { reverse(all(c)); for(auto e: c) if(t >= e) return e; } } } else { if(flag) { return c[sz - 1]; } else return c[0]; } return c[0]; }

Compilation message (stderr)

stations.cpp: In function 'int find_next_station(int, int, vi)':
stations.cpp:82:22: warning: unused variable 'e' [-Wunused-variable]
   82 |             for(auto e: c)
      |                      ^
#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...