Submission #1081695

#TimeUsernameProblemLanguageResultExecution timeMemory
1081695slivajanLongest Trip (IOI23_longesttrip)C++17
15 / 100
8 ms596 KiB
#include "longesttrip.h"
#include <bits/stdc++.h>

using namespace std;

typedef int un;
typedef vector<un> vuc;
typedef deque<un> duc;

#define REP(i, a, b) for (un i = (un)a; i < (un)b; i++)
#define FEAC(i, a) for (auto&& i : a)
#define ALL(x) (x).begin(), (x).end()
#define vec vector
#define DEB(x) cerr << #x << " = " << x << endl;

std::vector<int> longest_trip(int N, int D)
{
    if (D == 3){
        vuc ret(N);
        iota(ALL(ret), 0);
        return ret;
    }

    if (D == 2){
        duc ret;
        
        if (not are_connected({0}, {1})){
            ret = {0, 2, 1};
        }
        else if (not are_connected({1}, {2})){
            ret = {1, 0, 2};
        }
        else {
            ret = {0, 1, 2};
        }

        REP(i, 3, N){
            if (are_connected({ret.back()}, {i})){
                ret.push_back(i);
            }
            else{
                ret.push_front(i);
            }
        }

        return vuc(ALL(ret));
    }
}

Compilation message (stderr)

longesttrip.cpp: In function 'std::vector<int> longest_trip(int, int)':
longesttrip.cpp:48:1: warning: control reaches end of non-void function [-Wreturn-type]
   48 | }
      | ^
#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...