Submission #1052376

#TimeUsernameProblemLanguageResultExecution timeMemory
1052376errayIsland Hopping (JOI24_island)C++17
65 / 100
5 ms856 KiB
#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 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...