Submission #1204119

#TimeUsernameProblemLanguageResultExecution timeMemory
1204119LucaIlieIsland Hopping (JOI24_island)C++20
100 / 100
3 ms412 KiB

#include "island.h"
#include <bits/stdc++.h>

const int MAX_N = 300;
int depth[MAX_N + 1];
bool isCand[MAX_N + 1];
int parent[MAX_N + 1];

using namespace std;

void solve(int n, int l) {
    int root = 1;

    depth[root] = 0;
    queue<int> cand;
    cand.push(root);
    isCand[root] = true;
    for (int i = 1; i <= n - 1; i++) {
        int v = query(root, i);
        int p = parent[v];
        if (p == 0) {
            int j = 1;
            p = query(v, j);
            while (!isCand[p]) {
                parent[p] = v;
                j++;
                p = query(v, j);
            }
        }

        answer(p, v);
        depth[v] = depth[p] + 1;
        cand.push(v);
        isCand[v] = true;
        while (depth[cand.front()] + 1 < depth[v]) {
            isCand[cand.front()] = false;
            cand.pop();
        }
    }
}

#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...