Submission #996350

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
9963502024-06-10 13:37:38MilosMilutinovicLongest Trip (IOI23_longesttrip)C++17
100 / 100
12 ms612 KiB
#include "longesttrip.h"
#include <bits/stdc++.h>
using namespace std;
mt19937 rng(time(0));
vector<int> longest_trip(int n, int d) {
auto Ask = [&](vector<int> a, vector<int> b) {
return are_connected(a, b);
};
vector<int> idx(n);
iota(idx.begin(), idx.end(), 0);
shuffle(idx.begin(), idx.end(), rng);
vector<int> pa, pb;
pa.push_back(idx[0]);
pb.push_back(idx[1]);
bool know = false;
for (int ver = 2; ver < n; ver++) {
int i = idx[ver];
if (know) {
if (Ask({i}, {pa.back()})) {
pa.push_back(i);
know = false;
continue;
} else {
pb.push_back(i);
know = true;
continue;
}
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#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...