Submission #600826

#TimeUsernameProblemLanguageResultExecution timeMemory
600826MrBrionixStations (IOI20_stations)C++14
100 / 100
1214 ms768 KiB
#include<bits/stdc++.h> using namespace std; vector<int> grafo[1005]; int val[1005],tt; void dfs(int nodo, int mode, int last){ if(mode==0)val[nodo]=tt++; for(auto i : grafo[nodo]){ if(i!=last)dfs(i,mode^1,nodo); } if(mode==1)val[nodo]=tt++; } std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) { std::vector<int> labels(n); for(int i=0;i<n;i++)grafo[i].clear(); tt=0; for(int i=0;i<n-1;i++){ grafo[u[i]].push_back(v[i]); grafo[v[i]].push_back(u[i]); } dfs(0,0,-1); for (int i = 0; i < n; i++) { //cout<<i<<" "<<val[i]<<"\n"; labels[i] = val[i]; } return labels; } int find_next_station(int s, int t, std::vector<int> c) { bool mode; if(c[0]<s)mode=1; else mode=0; if(mode){ int last=s; for(int i=c.size()-1;i>0;i--){ if(t>=c[i] && t<last)return c[i]; last=c[i]; } return c[0]; }else{ int last=s; int st; if(s==0)st=c.size(); else st=c.size()-1; for(int i=0;i<st;i++){ if(t>last && t<=c[i])return c[i]; last=c[i]; } return c[c.size()-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...