# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1129799 | ohad | Island Hopping (JOI24_island) | C++20 | 0 ms | 0 KiB |
#include "island.h"
#include<bits/stdc++.h>
using namespace std;
void solve(int N, int L){
vector<int> father(N+1,-1);
father[1] = -2; //no father
vector<int> q;
for(int i = 1; i < N; i++){
q.push_back(query(1,i));
}
while(auto now : q){
for(int k = 1; father[now]==-1; k++){
int nei = query(now,k);
if(father[nei]!=-1) father[now]=nei;
else father[nei] = now;
}
}
for (int i = 2; i <= N; i++)
answer(i, father[i]);
}