This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "island.h"
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#include "/home/hp/contests/joi24scd4/debug.h"
#else
#define debug(...) void(37)
#endif
void solve(int N, int L) {
/*
int variable_example = query(1, 1);
for (int i = 2; i <= N; i++) {
answer(1, i);
}
*/
int root = 0;
vector<int> ord;
for (int i = 1; i < N; ++i) {
ord.push_back(query(root + 1, i) - 1);
}
vector<int> ind(N, -1);
for (int i = 0; i < N - 1; ++i) {
ind[ord[i]] = i;
}
vector<int> par(N, -1);
for (int i = N - 1; i > 0; --i) {
if (par[i] == -1) {
int v = i;
int s = 0;
do {
par[v] = i;
v = query(i + 1, ++s) - 1;
} while (ind[v] > ind[i]);
par[i] = v;
}
answer(i + 1, par[i] + 1);
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |