# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
831346 | Trumling | 기지국 (IOI20_stations) | C++14 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "stations.h"
#include <vector>
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define all(x) x.begin(),x.end()
typedef long long ll;
#define pb push_back
#define INF 9999999999999999
vector<vector<int>>g;
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
g.assign(n,vector<int>());
vector<bool>cnt(n,0);
for (int i = 0; i < n-1; i++) {
g[u[i]].pb(v[i]);
g[v[i]].pb(u[i]);
if(g[u[i]].size()==2)
cnt[u[i]]=1;
if(g[v[i]].size()==2)
cnt[v[i]]=1;
}
vector<int>labels(N);
for(int i=0;i<n;i++)
if(cnt[i])
{
ll start=i,pre=i;
ll idx=0;
while(true)
{
label[start]=idx++;
bool tf=0;
for(auto x:g[start])
if(x!=pre)
{
tf=1;
swap(start,pre);
start=x;
break;
}
if(!tf)
break;
}
break;
}
return labels;
}
int find_next_station(int s, int t, vector<int> c)
{
ll l=-1,r=INF;
if(c.size()==1)
{
if(c[0]<s)
l=c[0];
else
r=c[0];
}
else
{
l=min(c[0],c[1]);
r=max(c[0],c[1]);
}
if(t>s)
return r;
else
return l;
}