이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "longesttrip.h"
#include <bits/stdc++.h>
using namespace std;
#define sp " "
#define endl "\n"
#define fastio() cin.tie(0), ios_base::sync_with_stdio(0)
#define fileio() freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define pb push_back
#define pii pair<int, int>
#define st first
#define nd second
#define LL node * 2
#define RR node * 2 + 1
#define ll long long
const int modulo = 1e9 + 7;
const ll INF = 2e18 + 7;
vector<int> longest_trip(int N, int D)
{
vector<int> ans;
set<int> undone;
for (int i = 1; i < N; i++) undone.insert(i);
ans.pb(0);
while(!undone.empty()){
vector<int> tmp(undone.begin(), undone.end());
vector<int> a = {ans.back()};
int go = -1;
for (auto j : tmp){
vector<int> b = {j};
if (are_connected(a, b)){
go = j;
break;
}
}
if (go == -1){
int sz = ans.size();
if (sz * 2 >= N){
return ans;
}
return tmp;
}
else{
ans.pb(go);
undone.erase(go);
}
}
return ans;
}
# | 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... |