CompProgLibrary

This documentation is automatically generated by online-judge-tools/verification-helper

View the Project on GitHub RTnF/CompProgLibrary

:heavy_check_mark: cpp/array/doubling.hpp

Depends on

Required by

Verified with

Code

#pragma once
#include "template/small_template.hpp"

// ダブリング
// 値が[0, n)である配列のそれぞれで
// j = v[j] を 2**i 回繰り返した結果の2次元配列を作る
// O(n log kmax)
vector<vector<int>> doubling(vector<int> &v, uint64_t kmax) {
  // 0:0 1:1 2:2 4:3 8:4 ...
  assert(kmax > 0);
  int n = v.size();
  for (int i = 0; i < n; i++) {
    assert(0 <= v[i]);
    assert(v[i] < n);
  }
  int w = bit_width(kmax);
  vector<vector<int>> ret(w);
  ret[0].assign(v.begin(), v.end());
  for(int i = 1; i < w; i++){
    ret[i].reserve(n);
    for(int j = 0; j < n; j++){
      ret[i].emplace_back(ret[i-1][ret[i-1][j]]);
    }
  }
  return ret;
}
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.12.0/x64/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 "/opt/hostedtoolcache/Python/3.12.0/x64/lib/python3.12/site-packages/onlinejudge_verify/languages/cplusplus.py", line 187, in bundle
    bundler.update(path)
  File "/opt/hostedtoolcache/Python/3.12.0/x64/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 "/opt/hostedtoolcache/Python/3.12.0/x64/lib/python3.12/site-packages/onlinejudge_verify/languages/cplusplus_bundle.py", line 260, in _resolve
    raise BundleErrorAt(path, -1, "no such header")
onlinejudge_verify.languages.cplusplus_bundle.BundleErrorAt: template/small_template.hpp: line -1: no such header
Back to top page