This documentation is automatically generated by online-judge-tools/verification-helper
#include "Optimization/binary_search.hpp"めぐる式二分探索ㅤ |ok - ng| = 1 となるような (ng, ok) を見つけて、そのときの ok を返す
binary_search_01(ng, ok, f)binary_search_10(ok, ng, f)f(ng) = Falsef(ok) = True#pragma once
#include <bits/stdc++.h>
using namespace std;
// binary search
template<class T, class FUNC> T binary_search_01(T ng, T ok, const FUNC &f) {
while (abs(ok - ng) > 1) {
T mid = ok + ng >> 1;
if (f(mid)) ok = mid;
else ng = mid;
}
return ok;
}
template<class T, class FUNC> T binary_search_10(T ok, T ng, const FUNC &f) {
return binary_search_01(ng, ok, f);
}#line 2 "Optimization/binary_search.hpp"
#include <bits/stdc++.h>
using namespace std;
// binary search
template<class T, class FUNC> T binary_search_01(T ng, T ok, const FUNC &f) {
while (abs(ok - ng) > 1) {
T mid = ok + ng >> 1;
if (f(mid)) ok = mid;
else ng = mid;
}
return ok;
}
template<class T, class FUNC> T binary_search_10(T ok, T ng, const FUNC &f) {
return binary_search_01(ng, ok, f);
}