Submission #1064075

#TimeUsernameProblemLanguageResultExecution timeMemory
1064075new_accStations (IOI20_stations)C++14
15 / 100
620 ms820 KiB
#include "stations.h" #include<bits/stdc++.h> #define fi first #define se second using namespace std; typedef vector<int> vi; const int N=1e3+10; vi graf[N]; int val[N],li,kol[N]; void dfs(int v,int o){ li++; if(!kol[v]) val[v]=li; for(auto u:graf[v]){ if(u==o) continue; kol[u]=kol[v]^1; dfs(u,v); } li++; if(kol[v]) val[v]=li; } vi label(int n, int k, vi u,vi v) { for(int i=0;i<n;i++) graf[i].clear(),kol[i]=0,val[i]=0; li=0; for(int i=0;i<n-1;i++) graf[u[i]].push_back(v[i]),graf[v[i]].push_back(u[i]); dfs(0,0); vector<pair<int,int>> pom; for(int i=0;i<n;i++) pom.push_back({val[i],i}); sort(pom.begin(),pom.end()); vi labels(n); for(int i=0;i<n;i++) labels[pom[i].se]=i; return labels; } int find_next_station(int s,int t,vi c) { if(c.size()==1) return c[0]; if(c[0]>s){ // pre if(s==0){ for(auto u:c){ if(u>=t) return u; } return 0; } if(t>=s and t<=c[c.size()-2]){ for(auto u:c){ if(u>=t) return u; } return 0; }return c[c.size()-1]; }else{ if(t>c[0] and t<=s){ int ost=0; for(int i=1;i<(int)c.size();i++){ if(t>=c[i]) ost=c[i]; } return ost; }else return c[0]; } }
#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...