# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1065482 | boyliguanhan | Longest Trip (IOI23_longesttrip) | C++17 | 15 ms | 852 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>
using namespace std;
int findit(vector<int>v,vector<int>vf){
if(v.size()==1)return v[0];
vector<int>v1,v2;
for(auto i:v)
v1.push_back(i),
swap(v1,v2);
if(are_connected(v1,vf))
return findit(v1,vf);
return findit(v2,vf);
}
mt19937 rng(0);
vector<int> longest_trip(int N, int D){
vector<int>path1,path2,v(N);
iota(v.begin(),v.end(),0);
shuffle(v.begin(),v.end(),rng);
path1={v[0]},path2={v[1]};
for(int i=1;i*2+1<N;i++){
int U=v[i*2],V=v[i*2+1];
int a=are_connected({U},{path1.back()});
if(are_connected({U},{V})){
int b=are_connected({U},{path2.back()});
if(a) path1.push_back(U),
path1.push_back(V);
else if(b)
path2.push_back(U),
path2.push_back(V);
else{ reverse(path2.begin(),path2.end());
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... |