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"
#include <bits/stdc++.h>
using namespace std;
long long nn,sq[1069];
vector<long long> al[1069];
bitset<1069> vtd;
void dfs(long long x,bool bad)
{
long long i,sz=al[x].size(),l;
vtd[x]=1;
if(!bad)
{
sq[x]=nn;
nn++;
}
for(i=0;i<sz;i++)
{
l=al[x][i];
if(!vtd[l])
{
dfs(l,!bad);
}
}
if(bad)
{
sq[x]=nn;
nn++;
}
}
vector<int> label(int n,int d,vector<int> ka,vector<int> la)
{
long long i,k,l;
vector<int> v;
for(i=0;i<n;i++)
{
al[i].clear();
vtd[i]=0;
}
for(i=0;i<n-1;i++)
{
k=ka[i];
l=la[i];
al[k].push_back(l);
al[l].push_back(k);
}
nn=0;
dfs(0,0);
for(i=0;i<n;i++)
{
v.push_back(sq[i]);
}
return v;
}
int find_next_station(int x,int y,vector<int> a)
{
long long i,sz=a.size();
if(x>a[0])
{
x*=-1;
y*=-1;
for(i=0;i<sz;i++)
{
a[i]*=-1;
}
}
sort(a.begin(),a.end());
if(y<x||y>a[sz-1])
{
return abs(a[sz-1]);
}
else
{
return abs(*lower_bound(a.begin(),a.end(),y));
}
}
# | 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... |