Submission #350728

#TimeUsernameProblemLanguageResultExecution timeMemory
350728KerimStations (IOI20_stations)C++17
100 / 100
1043 ms1368 KiB
#include "stations.h" #include "bits/stdc++.h" #define MAXN 1009 #define INF 1000000007 #define mp(x,y) make_pair(x,y) #define all(v) v.begin(),v.end() #define pb(x) push_back(x) #define wr cout<<"----------------"<<endl; #define ppb() pop_back() #define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++) #define ff first #define ss second #define my_little_dodge 46 #define debug(x) cerr<< #x <<" = "<< x<<endl; using namespace std; typedef long long ll; typedef pair<int,int> PII; template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;} template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;} int T,n; vector<int>adj[MAXN],labels; void dfs(int nd,int pr,int lvl){ if(!lvl)labels[nd]=T++; tr(it,adj[nd]) if(*it!=pr) dfs(*it,nd,lvl^1); if(lvl)labels[nd]=T++; } vector<int> label(int N, int k,vector<int> u, std::vector<int> v) { n=N;T=0;labels.clear(); labels.resize(n); for(int i=0;i<n;i++)adj[i].clear(); for(int i=0;i<n-1;i++){ adj[u[i]].pb(v[i]); adj[v[i]].pb(u[i]); } dfs(0,-1,0); return labels; } int find_next_station(int s, int t, vector<int> c) { sort(all(c));int m=int(c.size()); if(!s){ tr(it,c) if(t<=*it) return *it; } if(s<c[0]){ int in=s,out=c[m-1]-1; if(in<t and t<=out){ tr(it,c) if(t<=*it) return *it; } return c.back(); } else{ int in=c[0]+1,out=s; if(in<=t and t<out){ for(int i=m-1;i>=0;i--) if(c[i]<=t) return c[i]; } return c[0]; } return -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...