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>
#define ss second
#define all(s) s.begin(),s.end()
#define sz(s) ll(s.size())
#define pb push_back
typedef long long ll;
const ll MAX=1e6;
using namespace std;
ll marc=1;
vector<ll> gfo[MAX];
ll m[MAX];
void dfs(int u, int f){
m[u]=marc;
for(auto v:gfo[u]){
if(v!=f){
marc++;
dfs(v,u);
}
}
}
vector<int> label(int n, int k, vector<int> u, vector<int> v){
vector<int> labels(n);
for(int i=0; i<sz(u); i++){
gfo[u[i]].pb(v[i]);
gfo[v[i]].pb(u[i]);
}
for(int i=0; i<n; i++){
if(sz(gfo[i])==1 && labels[i]==0){
dfs(i, i);
}
// cout<<i<<'\n';
// for(auto v:gfo[i]){
// cout<<v<<' ';
// }
// cout<<'\n';
}
for(int i=0; i<n; i++){
labels[i]=m[i];
}
return labels;
}
int find_next_station(int s, int t, vector<int> c){
sort(all(c));
if(s>t){
return c[0];
}
return c[sz(c)-1];
}
# | 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... |