# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
399722 | A_D | Fun Tour (APIO20_fun) | C++14 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int N=5011;
set<int> g[N];
int n,uu;
int d;
void dfs(int u,int p,int dep)
{
if(dep>d){
d=dep;
uu=u;
}
for(auto x:g[u]){
if(x==p)continue;
dfs(x,u,dep+1);
}
}
std::vector<int> createFunTour(int N, int Q) {
//int H = hoursRequired(0, N - 1);
//int A = attractionsBehind(0, N - 1);
return std::vector<int>(N);
n=N;
for(int i=0;i<n;i++){
for(int j=i+1;j<n;j++){
int h=hoursRequired(i, j);
if(h==1){
g[i].insert(j);
g[j].insert(i);
}
}
}
vector<int> ret;
d=0;
dfs(uu,uu,0);
while(g[uu].empty()==0){
d=0;
int v=uu;
ret.push_back(v);
dfs(uu,uu,0);
int x=*g[v].begin();
g[v].erase(x);
g[x].erase(v);
}
return ret;
}