# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
938938 | AdamGS | Longest Trip (IOI23_longesttrip) | C++17 | 12 ms | 952 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;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
vector<int>longest_trip(int n, int d) {
vector<pair<int,int>>X, Y;
vector<int>A, B;
rep(i, n/2) if(are_connected({2*i}, {2*i+1})) X.pb({2*i, 2*i+1}); else Y.pb({2*i, 2*i+1});
if(n%2==1) A.pb(n-1);
for(auto i : X) {
if(A.size()==0) {
A.pb(i.st);
A.pb(i.nd);
continue;
}
if(B.size()==0) {
B.pb(i.st);
B.pb(i.nd);
continue;
}
if(are_connected({A.back()}, {i.st})) {
A.pb(i.st);
A.pb(i.nd);
continue;
}
if(are_connected({B.back()}, {i.st})) {
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... |