# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
988602 | Gray | Longest Trip (IOI23_longesttrip) | C++17 | 858 ms | 2372 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 "longesttrip.h"
#include<bits/stdc++.h>
#include <cassert>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define ln endl
vector<vector<ll>> A;
ll n, d;
std::vector<int> longest_trip(int N, int D)
{
n=N; d=D;
A.clear();
A.resize(N);
for (ll i=0; i<n; i++){
for (ll j=i+1; j<n; j++){
if (are_connected({(int)i}, {(int)j})){
A[i].push_back(j);
A[j].push_back(i);
}
}
}
vector<ll> semi;
for (ll i=0; i<n; i++){
if (A[i].size()<n-1){
semi.push_back(i);
}
}
assert(semi.size()==0 or semi.size()==2);
vector<int> ans;
if (semi.size()==0){
for (ll i=0; i<n; i++) ans.push_back(i);
}else{
ans.push_back(semi[0]);
for (ll i=0; i<n; i++){
if (i!=semi[0] and i!=semi[1]){
ans.push_back(i);
}
}
ans.push_back(semi[1]);
}
return ans;
}
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... |