Submission #1243075

#TimeUsernameProblemLanguageResultExecution timeMemory
1243075nvujicaLongest Trip (IOI23_longesttrip)C++20
30 / 100
5 ms416 KiB
#include "longesttrip.h"
#include <bits/stdc++.h>

using namespace std;

vector<int> longest_trip(int n, int d){
    vector <int> a, b;

    a.push_back(0);
    
    // int x = 1;

    // while(x < n && are_connected({0}, {x})){
    //     a.push_back(x);
    //     x++;
    // }
    
    // if(x == n) return a;

    // b.push_back(x);

    for(int i = 1; i < n; i++){
        if(are_connected({a.back()}, {i})) a.push_back(i);
        else b.push_back(i);

        if(!b.empty() && are_connected({a.back()}, {b.back()})){
            while(!b.empty()){
                a.push_back(b.back());
                b.pop_back();
            }
        }
    }

    if(a.size() > b.size()) return a;
    return b;
}
#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...