# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1202808 | walizamanee | Fish 3 (JOI24_fish3) | C++20 | 0 ms | 0 KiB |
#include<bits/stdc++.h>
#include "routers.h"
using namespace std;
vector<int> find_routers(int l, int n, int q) {
//int idx = use_detector(0);
vector<int> ans;
ans.clear();
ans.push_back(0);
set<pair<int , int>> op;
op.insert({l + 1 , n});
int here = 0;
int bam , dan , m ;
pair<int , int> itt;
for( int z = 1; z < n; z++ ) {
bam = here;
dan = l;
auto it = op.lower_bound({bam + 1 , 0});
itt = *it;
while( itt.second <= z - 1 ) {
bam = itt.first;
it = op.lower_bound({bam + 1 , 0});
itt = *it;
}
dan = itt.first - 1;
while( bam < dan ) {
m = (bam + dan + 1) / 2;
int chek = use_detector(m);
op.insert({m , chek});
if( chek == z - 1 ) bam = m;
else dan = m - 1;
}
ans.push_back(bam + bam - here);
here = bam + bam - here;
}
return ans;
}
/*int main() {
return 0;
} */