Neterukun's Library

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

View the Project on GitHub Neterukun1993/Library

:heavy_check_mark: TestCase/LibraryChecker/queue_operate_all_composite.BootstrappedFoldableQueue.test.py

Depends on

Code

# verification-helper: PROBLEM https://judge.yosupo.jp/problem/queue_operate_all_composite
import sys
input = sys.stdin.buffer.readline

from DataStructure.misc.BootstrappedFoldableQueue import BootstrappedFoldableQueue


MOD = 998244353
MASK = (1 << 32) - 1


def X_f(x1, x2):
    x = x1 + x2
    return ((x >> 32) % MOD << 32) + (x & MASK) % MOD


def XA_map(x, a):
    x0, x1 = x >> 32, x & MASK
    a0, a1 = a >> 32, a & MASK
    return (((x0 * a0 + x1 * a1) % MOD) << 32) + x1


def A_f(a1, a2):
    a10, a11 = a1 >> 32, a1 & MASK
    a20, a21 = a2 >> 32, a2 & MASK
    return ((a20 * a10 % MOD) << 32) + (a20 * a11 + a21) % MOD


def main():
    q = int(input())
    queries = [list(map(int, input().split())) for i in range(q)]

    bfq = BootstrappedFoldableQueue(A_f)
    ans = []
    for query in queries:
        if query[0] == 0:
            _, a, b = query
            bfq = bfq.snoc((a << 32) + b)
        elif query[0] == 1:
            bfq = bfq.tail()
        else:
            _, x = query
            if len(bfq) == 0:
                ans.append(x)
            else:
                a = bfq.all_fold()
                res = XA_map((x << 32) + 1, a)
                ans.append(res >> 32)

    print('\n'.join(map(str, ans)))


if __name__ == '__main__':
    main()
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.12.4/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.4/x64/lib/python3.12/site-packages/onlinejudge_verify/languages/python.py", line 96, in bundle
    raise NotImplementedError
NotImplementedError
Back to top page