# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
750386 | mohav48173 | Stations (IOI20_stations) | C++14 | 961 ms | 788 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "stations.h"///15:49
#include<bits/stdc++.h>
using namespace std;
vector<int>cur;
vector<int>a[1001];
int counter;
void dfs(int n,int par=-1,int depth=0) {
if(depth%2==0)cur[n]=counter++;
for(int i:a[n]) {
if(i!=par)dfs(i,n,depth+1);
}
if(depth%2==1)cur[n]=counter++;
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
cur=vector<int>(n,0);
for(int i=0;i<n;i++){a[i].clear();}
counter=0;
for(int i=0;i<n-1;i++) {
a[u[i]].push_back(v[i]);
a[v[i]].push_back(u[i]);
}
dfs(0);
return cur;
}
int find_next_station(int s, int t, vector<int> c) {
if(c.size()==1)return c[0];
int par=-1;
if(s<c[0])par=c[c.size()-1];
else par=c[0];
c.erase(find(c.begin(),c.end(),par));
if(par<s) {
if(t>s || t<c[0])return par;
for(int i=0;i<c.size();i++) {
if(i==c.size()-1 || c[i+1]>t)return c[i];
}
} else {
if(t<s || t>c[c.size()-1])return par;
for(int i=0;i<c.size();i++) {
if(t<=c[i])return c[i];
}
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |