# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
423416 | Belgutei | Stations (IOI20_stations) | C++17 | 1097 ms | 648 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"
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mk make_pair
vector<int> edge[1005];
bool visited[1005];
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
for(int i=0; i<n; i++) edge[i].clear();
for(int i=0; i<n; i++) visited[i]=0;
for(int i=0; i<u.size(); i++){
edge[u[i]].pb(v[i]);
edge[v[i]].pb(u[i]);
}
int pos=0;
for(int i=0; i<n; i++){
if(edge[i].size()==1){
pos=i;
break;
}
}
std::vector<int> labels(n);
int cnt=0;
while(visited[pos]==0){
labels[pos]=cnt;
visited[pos]=1;
for(int i=0; i<edge[pos].size(); i++){
if(visited[edge[pos][i]]==0){
pos=edge[pos][i];
break;
}
}
cnt++;
}
/*
cout<<"\n";
for(int i=0; i<n; i++){
cout<<labels[i]<<" ";
}
*/
return labels;
}
int find_next_station(int s, int t, std::vector<int> c) {
if(c.size()==1){
return c[0];
}
int mx=max(c[0],c[1]);
int mn=min(c[0],c[1]);
if(s>t) return mn;
else return mx;
}
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... |