Submission #985527

#TimeUsernameProblemLanguageResultExecution timeMemory
985527Alex0x0Stations (IOI20_stations)C++14
0 / 100
559 ms936 KiB
// #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math") // #pragma GCC target("avx,avx2,fma") #include <bits/stdc++.h> #define f first #define s second #define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i) #define pb push_back #define all(s) begin(s), end(s) #define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define sz(s) int(s.size()) #define ENDL '\n' using namespace std; typedef long double ld; typedef int lli; typedef pair<lli,lli> ii; typedef vector<lli> vi; typedef vector<ii> vii; #define deb(x) cout << #x": " << (x) << endl; const lli INF = 1e9 + 12; const lli N = 1e3 + 12; vector <vi> adj; vi tk; lli curVis = 0; lli titi = 0; lli vis[N]; lli dfs(lli u, lli dpth){ // cout << u << ' '; vis[u] = curVis; if (dpth % 2 == 1) tk[u] = titi++; for (auto & i : adj[u]){ if (vis[i] == curVis) continue; dfs(i, dpth+1); } if (dpth % 2 == 0) tk[u] = titi++; return tk[u]; } vi label(lli n, lli k, vi u, vi v){ adj.resize(n + 5); for (auto &i : adj) i.clear(); tk.resize(n); for (auto &i : tk) i = -1ll; titi = 0; fore(i,0,n-1){ adj[u[i]].pb(v[i]); adj[v[i]].pb(u[i]); } ++curVis; dfs(0, 0); // cout << ENDL; return tk; } lli find_next_station(lli s, lli t, vi c){ sort(all(c)); bool minor = true; for (auto & i : c) if (i > s) minor = false; if (minor){ fore(i,0,sz(c)-1) if (s <= t && t <= c[i]) return c[i]; return c[sz(c)-1]; } else{ fore(i,1,sz(c)){ lli xx = s; if ((i + 1) < sz(c)) xx = c[i + 1]; if (c[i] <= t && t <= xx) return c[i]; } return c[0]; } return c[sz(c)-1]; }
#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...