Submission #615269

#TimeUsernameProblemLanguageResultExecution timeMemory
615269alirezasamimi100Stations (IOI20_stations)C++17
0 / 100
883 ms668 KiB
#include "stations.h" #include <bits/stdc++.h> using namespace std; #define pb push_back const int N = 1e3 + 10; int t=-1; vector<int> ans,adj[N]; void dfs(int v, int p, int c){ if(!c) ans[v]=++t; for(int u : adj[v]) if(u!=p) dfs(u,v,1-c); if(c) ans[v]=++t; } vector<int> label(int n, int k, vector<int> u, vector<int> v) { ans.resize(n); t=-1; for(int i=0; i<n; i++) adj[i].clear(); for(int i=0; i<(int)v.size(); i++){ adj[v[i]].pb(u[i]); adj[u[i]].pb(v[i]); } dfs(0,-1,0); return ans; } int find_next_station(int s, int t, vector<int> c) { int k; if(s<c[0]){ k=c.back(); if(s) c.pop_back(); if(t<s || t>c.back()) return k; return *lower_bound(c.begin(),c.end(),t); }else{ k=c[0]; c.erase(c.begin()); if(t<c[0] || t>s) return k; return *(upper_bound(c.begin(),c.end(),t)-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...