結果
| 問題 |
No.151 セグメントフィッシング
|
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 13:08:56 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,398 bytes |
| コンパイル時間 | 255 ms |
| コンパイル使用メモリ | 82,660 KB |
| 実行使用メモリ | 85,672 KB |
| 最終ジャッジ日時 | 2025-06-12 13:12:28 |
| 合計ジャッジ時間 | 7,687 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 3 TLE * 1 -- * 15 |
ソースコード
import sys
def main():
input = sys.stdin.read().split()
ptr = 0
N = int(input[ptr])
ptr += 1
Q = int(input[ptr])
ptr += 1
groups = []
for _ in range(Q):
query = input[ptr]
ptr += 1
y = int(input[ptr])
ptr += 1
z = int(input[ptr])
ptr += 1
if query == 'C':
current_time = _ + 1 # queries are 1-indexed
y_query = y
z_query = z
total = 0
for group in groups:
t0, y0, direction, count = group
if t0 > current_time:
continue
k = current_time - t0
pos = y0
dir = 1 if direction == 'R' else -1
for _ in range(k):
if dir == 1:
if pos < N - 1:
pos += 1
else:
dir = -1
else:
if pos > 0:
pos -= 1
else:
dir = 1
if y_query <= pos < z_query:
total += count
print(total)
else:
direction = query
t0 = _ + 1 # queries are 1-indexed
groups.append((t0, y, direction, z))
if __name__ == '__main__':
main()
gew1fw