Submission #1239888

#TimeUsernameProblemLanguageResultExecution timeMemory
1239888banganLongest Trip (IOI23_longesttrip)C++20
15 / 100
3 ms416 KiB
#include "longesttrip.h"
#include <bits/stdc++.h>
using namespace std;

bool check(int v, int u) {
    return are_connected({v}, {u});
}

std::vector<int> longest_trip(int N, int D) {
    deque<int> ans;
    if (!check(0, 1)) ans = {0, 2, 1};
    else if (!check(0, 2)) ans = {0, 1, 2};
    else ans = {1, 0, 2};
    for (int x=3; x<N; x++) {
        int v = ans.front();
        int u = ans.back();
        if (!check(x, v)) ans.push_back(x);
        else ans.push_front(x);
    }
    vector<int> ret;
    while (!ans.empty()) {
        ret.push_back(ans.back());
        ans.pop_back();
    }
    return ret;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...