Submission #855156

#TimeUsernameProblemLanguageResultExecution timeMemory
855156evenvalueLongest Trip (IOI23_longesttrip)C++17
0 / 100
1 ms344 KiB
#include "longesttrip.h"
#include <bits/stdc++.h>
using namespace std;

template<typename T>
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using max_heap = priority_queue<T, vector<T>, less<T>>;

using int64 = long long;
using ld = long double;

constexpr int kInf = 1e9 + 10;
constexpr int64 kInf64 = 1e15 + 10;
constexpr int kMod = 1e9 + 7;

std::vector<int> longest_trip(int N, int D) {
  deque<int> longest_path;
  
  for (int i = 0; i < 3; i++) {
    const int j = (i + 1) % 3;
    if (not are_connected({i}, {j})) {
      longest_path = {i, (i + 2) % 3, j};
    }
  }
  
  for (int x = 3; x < N; x++) {
    const int y = longest_path.back();
    if (are_connected({x}, {y})) {
      longest_path.push_back(x);
    } else {
      longest_path.push_front(x);
    }
  }
  
  vector<int> ans;
  for (const int x : longest_path) {
    ans.push_back(x);
  }
  
  return ans;
}
#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...