結果
問題 |
No.469 区間加算と一致検索の問題
|
ユーザー |
![]() |
提出日時 | 2020-03-24 21:44:02 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 1,309 ms / 5,000 ms |
コード長 | 589 bytes |
コンパイル時間 | 466 ms |
コンパイル使用メモリ | 12,032 KB |
実行使用メモリ | 31,440 KB |
最終ジャッジ日時 | 2025-01-01 18:21:03 |
合計ジャッジ時間 | 30,107 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 49 |
ソースコード
#!/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