結果
| 問題 | No.469 区間加算と一致検索の問題 |
| コンテスト | |
| ユーザー |
maspy
|
| 提出日時 | 2020-03-24 21:44:02 |
| 言語 | Python3 (3.15.0 + numpy 2.5.4 + scipy 1.18.1 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 1,053 ms / 5,000 ms |
| + 643µs | |
| コード長 | 589 bytes |
| 記録 | |
| コンパイル時間 | 96 ms |
| コンパイル使用メモリ | 14,848 KB |
| 実行使用メモリ | 31,844 KB |
| 最終ジャッジ日時 | 2026-10-23 08:53:48 |
| 合計ジャッジ時間 | 27,812 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 51 |
ソースコード
#!/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
maspy