結果

問題 No.469 区間加算と一致検索の問題
ユーザー H3PO4H3PO4
提出日時 2021-07-17 08:53:37
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,590 ms / 5,000 ms
コード長 407 bytes
コンパイル時間 115 ms
コンパイル使用メモリ 10,792 KB
実行使用メモリ 23,196 KB
最終ジャッジ日時 2023-09-21 01:34:44
合計ジャッジ時間 38,415 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
8,752 KB
testcase_01 AC 19 ms
8,792 KB
testcase_02 AC 19 ms
8,904 KB
testcase_03 AC 50 ms
9,320 KB
testcase_04 AC 62 ms
9,272 KB
testcase_05 AC 66 ms
9,572 KB
testcase_06 AC 75 ms
9,744 KB
testcase_07 AC 81 ms
9,696 KB
testcase_08 AC 82 ms
9,780 KB
testcase_09 AC 45 ms
9,324 KB
testcase_10 AC 60 ms
9,008 KB
testcase_11 AC 37 ms
9,128 KB
testcase_12 AC 83 ms
9,632 KB
testcase_13 AC 58 ms
9,440 KB
testcase_14 AC 31 ms
9,172 KB
testcase_15 AC 35 ms
9,084 KB
testcase_16 AC 75 ms
9,672 KB
testcase_17 AC 74 ms
9,748 KB
testcase_18 AC 79 ms
9,732 KB
testcase_19 AC 29 ms
8,972 KB
testcase_20 AC 80 ms
9,580 KB
testcase_21 AC 34 ms
9,052 KB
testcase_22 AC 20 ms
8,764 KB
testcase_23 AC 591 ms
15,748 KB
testcase_24 AC 598 ms
15,804 KB
testcase_25 AC 599 ms
15,780 KB
testcase_26 AC 593 ms
15,796 KB
testcase_27 AC 589 ms
15,976 KB
testcase_28 AC 595 ms
15,808 KB
testcase_29 AC 591 ms
15,972 KB
testcase_30 AC 585 ms
15,772 KB
testcase_31 AC 590 ms
15,760 KB
testcase_32 AC 591 ms
15,788 KB
testcase_33 AC 1,543 ms
23,196 KB
testcase_34 AC 1,546 ms
23,080 KB
testcase_35 AC 1,562 ms
23,152 KB
testcase_36 AC 1,561 ms
23,192 KB
testcase_37 AC 1,590 ms
23,068 KB
testcase_38 AC 1,564 ms
16,404 KB
testcase_39 AC 1,528 ms
16,332 KB
testcase_40 AC 1,546 ms
16,432 KB
testcase_41 AC 1,539 ms
16,372 KB
testcase_42 AC 1,574 ms
16,312 KB
testcase_43 AC 1,525 ms
16,424 KB
testcase_44 AC 1,556 ms
16,444 KB
testcase_45 AC 1,551 ms
16,336 KB
testcase_46 AC 1,545 ms
16,276 KB
testcase_47 AC 1,526 ms
16,416 KB
testcase_48 AC 19 ms
8,780 KB
testcase_49 AC 18 ms
8,972 KB
testcase_50 AC 1,563 ms
16,444 KB
testcase_51 AC 1,531 ms
16,500 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import random

N, Q = map(int, input().split())
MOD = (1 << 61) - 1
BASE = random.randrange(2, MOD)
cur = 0
d = {0: 0}
for i in range(1, Q + 1):
    query = input().split()
    if query[0] == '!':
        L, R, K = map(int, query[1:])
        cur += K * pow(BASE, L, MOD)
        cur -= K * pow(BASE, R, MOD)
        cur %= MOD
        if cur not in d:
            d[cur] = i
    else:
        print(d[cur])
0