Submission #1238452

#TimeUsernameProblemLanguageResultExecution timeMemory
1238452t_hollIsland Hopping (JOI24_island)C++20
100 / 100
3 ms408 KiB
#include "island.h" #include <bits/stdc++.h> using namespace std; void solve(int N, int L) { vector<bool> found(N + 1); found[1] = true; // Iterate over the BFS starting at 1 for (int k = 1; k < N; k ++) { int i = query(1, k); // N queries // found represents if the parent is already linked to the node // if yes we don't have anything to do if (found[i]) continue ; found[i] = true; // otherwise we search for the adjacent nodes, if it is the parent we stop // otherwise we set the next to found and answer that. // thus each link is visited once for N - 1 queries int off = 1; int nxt = -1; do { if (nxt != -1) found[nxt] = true; nxt = query(i, off ++); answer(i, nxt); } while (!found[nxt]); } }
#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...