# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1007032 | 3as8 | 가장 긴 여행 (IOI23_longesttrip) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "longesttrip.h"
#include<bits/stdc++.h>
#define ll long long
using namespace std;
bool con[300][300];
bool vis[300];
ll n;
ll l = 0;
void dfs(ll startIndex, vector<int>& curr) {
vis[startIndex] = true;
curr.push_back(startIndex);
bool in = false;
for(int i = 0; i < n; i++) {
if(!vis[i] && are_connected({startIndex}, {i});) {
dfs(i, curr);
in = true;
}
}
if(!in) l = startIndex;
}
std::vector<int> longest_trip(int N, int D) {
n = N;
vector<ll> ans;
ll mx = LLONG_MIN;
for(int j = 0; j < n; j++) vis[j] = false;
vector<int> curr;
for(int j = 0; j < n; j++) vis[j] = false;
vector<int> curr2;
dfs(0, curr);
dfs(l, curr2);
return curr2;
}