結果

問題 No.469 区間加算と一致検索の問題
ユーザー maspymaspy
提出日時 2020-03-24 21:44:02
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,122 ms / 5,000 ms
コード長 589 bytes
コンパイル時間 144 ms
コンパイル使用メモリ 10,592 KB
実行使用メモリ 29,648 KB
最終ジャッジ日時 2023-08-30 08:54:05
合計ジャッジ時間 28,023 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
8,604 KB
testcase_01 AC 18 ms
8,424 KB
testcase_02 AC 19 ms
8,580 KB
testcase_03 AC 36 ms
9,408 KB
testcase_04 AC 45 ms
9,544 KB
testcase_05 AC 46 ms
9,764 KB
testcase_06 AC 50 ms
9,916 KB
testcase_07 AC 55 ms
9,936 KB
testcase_08 AC 55 ms
9,964 KB
testcase_09 AC 35 ms
9,256 KB
testcase_10 AC 39 ms
9,220 KB
testcase_11 AC 29 ms
8,844 KB
testcase_12 AC 56 ms
9,956 KB
testcase_13 AC 42 ms
9,536 KB
testcase_14 AC 25 ms
8,884 KB
testcase_15 AC 27 ms
9,044 KB
testcase_16 AC 50 ms
9,864 KB
testcase_17 AC 50 ms
9,816 KB
testcase_18 AC 55 ms
9,808 KB
testcase_19 AC 24 ms
8,656 KB
testcase_20 AC 53 ms
9,932 KB
testcase_21 AC 28 ms
8,800 KB
testcase_22 AC 19 ms
8,592 KB
testcase_23 AC 410 ms
18,612 KB
testcase_24 AC 409 ms
18,492 KB
testcase_25 AC 408 ms
18,544 KB
testcase_26 AC 409 ms
18,608 KB
testcase_27 AC 410 ms
18,384 KB
testcase_28 AC 412 ms
18,556 KB
testcase_29 AC 403 ms
18,608 KB
testcase_30 AC 411 ms
18,608 KB
testcase_31 AC 411 ms
18,656 KB
testcase_32 AC 403 ms
18,564 KB
testcase_33 AC 1,113 ms
29,528 KB
testcase_34 AC 1,122 ms
29,648 KB
testcase_35 AC 1,103 ms
29,564 KB
testcase_36 AC 1,117 ms
29,636 KB
testcase_37 AC 1,115 ms
29,520 KB
testcase_38 AC 1,095 ms
23,048 KB
testcase_39 AC 1,095 ms
23,060 KB
testcase_40 AC 1,099 ms
22,892 KB
testcase_41 AC 1,111 ms
22,984 KB
testcase_42 AC 1,103 ms
22,972 KB
testcase_43 AC 1,105 ms
22,956 KB
testcase_44 AC 1,104 ms
23,108 KB
testcase_45 AC 1,115 ms
23,052 KB
testcase_46 AC 1,102 ms
23,104 KB
testcase_47 AC 1,092 ms
22,964 KB
testcase_48 AC 19 ms
8,504 KB
testcase_49 AC 19 ms
8,500 KB
testcase_50 AC 1,105 ms
23,132 KB
testcase_51 AC 1,105 ms
22,960 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/ python3.8
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from collections import defaultdict


N, Q = map(int, readline().split())

MOD = 10 ** 16 + 61
B = 12345
H = [0] * Q

first_time = dict()
x = 0
first_time[x] = 0
for i, query in enumerate(readlines(), 1):
    if query.startswith(b'?'):
        print(first_time[x])
    else:
        L, R, K = map(int, query[2:].split())
        x += K * (pow(B, R, MOD) - pow(B, L, MOD))
        x %= MOD
        if x not in first_time:
            first_time[x] = i
0