serna37's Library

Logo

C++ アルゴリズムとデータ構造のライブラリ

View the Project on GitHub serna37/library-cpp

:heavy_check_mark: 二分探索 要素数のテスト
(tests/search.binary_search.bi_search_cnt.test.cpp)

Depends on

Code

#define PROBLEM                                                                \
    "https://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_4_B"
#include "template/template.hpp"
#include "library/search/binary_search/bi_ge_cnt.hpp"
#include "library/search/binary_search/bi_gt_cnt.hpp"
#include "library/search/binary_search/bi_le_cnt.hpp"
#include "library/search/binary_search/bi_lt_cnt.hpp"
/**
 * @brief 二分探索 要素数のテスト
 */
void solve() {
    int N;
    cin >> N;
    vector<int> A(N);
    cin >> A;
    sort(A.begin(), A.end());
    int Q;
    cin >> Q;
    int ans = 0;
    while (Q--) {
        int x;
        cin >> x;
        // 以上の数 - より大きい数
        int cnt_ge = bi_ge_cnt(A, x);
        int cnt_gt = bi_gt_cnt(A, x);
        int match_cnt = cnt_ge - cnt_gt;
        if (0 < match_cnt) ++ans;
        // 以下の数 - より小さい数
        int cnt_le = bi_le_cnt(A, x);
        int cnt_lt = bi_lt_cnt(A, x);
        int match_cnt2 = cnt_le - cnt_lt;
        assert(match_cnt == match_cnt2);
    }
    print(ans);
}
Traceback (most recent call last):
  File "/home/runner/.local/lib/python3.12/site-packages/onlinejudge_verify/documentation/build.py", line 71, in _render_source_code_stat
    bundled_code = language.bundle(stat.path, basedir=basedir, options={'include_paths': [basedir]}).decode()
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/.local/lib/python3.12/site-packages/onlinejudge_verify/languages/cplusplus.py", line 187, in bundle
    bundler.update(path)
  File "/home/runner/.local/lib/python3.12/site-packages/onlinejudge_verify/languages/cplusplus_bundle.py", line 401, in update
    self.update(self._resolve(pathlib.Path(included), included_from=path))
  File "/home/runner/.local/lib/python3.12/site-packages/onlinejudge_verify/languages/cplusplus_bundle.py", line 400, in update
    raise BundleErrorAt(path, i + 1, "unable to process #include in #if / #ifdef / #ifndef other than include guards")
onlinejudge_verify.languages.cplusplus_bundle.BundleErrorAt: template/template.hpp: line 7: unable to process #include in #if / #ifdef / #ifndef other than include guards
Back to top page