Submission #1310202

#TimeUsernameProblemLanguageResultExecution timeMemory
1310202AliMark71Longest Trip (IOI23_longesttrip)C++20
0 / 100
1 ms332 KiB
#include "longesttrip.h"
#include <bits/stdc++.h>

template<typename T>
using vec = std::vector<T>;
using namespace std;

std::vector<int> longest_trip(int N, int D)
{
    vec<int> nodes(N); for (int i = 1; i <= N; i++) nodes[i - 1] = i;
    if (D == 3)
        return nodes;
    if (D == 2) {
        deque<int> path{1, are_connected({1}, {2}) ? 2 : 3};
        nodes.erase(find(nodes.begin(), nodes.end(), path.front()));
        nodes.erase(find(nodes.begin(), nodes.end(), path.back()));
        
        while (!nodes.empty()) {
            auto u = nodes.back(); nodes.pop_back();
            if (are_connected({path.front()}, {u}))
                path.push_front(u);
            else
                path.push_back(u);
        }
        
        return vec<int>(path.begin(), path.end());
    }
    
    volatile char* p = 0;
    return {*p = 0}; // womp womp
}

Compilation message (stderr)

longesttrip.cpp: In function 'std::vector<int> longest_trip(int, int)':
longesttrip.cpp:30:16: warning: using value of assignment with 'volatile'-qualified left operand is deprecated [-Wvolatile]
   30 |     return {*p = 0}; // womp womp
      |             ~~~^~~
#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...