結果
| 問題 |
No.259 セグメントフィッシング+
|
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 20:06:24 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,655 bytes |
| コンパイル時間 | 198 ms |
| コンパイル使用メモリ | 81,924 KB |
| 実行使用メモリ | 53,628 KB |
| 最終ジャッジ日時 | 2025-06-12 20:12:57 |
| 合計ジャッジ時間 | 6,024 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 5 TLE * 1 -- * 17 |
ソースコード
import sys
def main():
input = sys.stdin.read().split()
ptr = 0
N = int(input[ptr])
ptr += 1
Q = int(input[ptr])
ptr += 1
batches = [] # list of tuples (t0, y, direction, z)
for _ in range(Q):
cmd = input[ptr]
ptr += 1
t = int(input[ptr])
ptr += 1
y = int(input[ptr])
ptr += 1
z = int(input[ptr])
ptr += 1
if cmd == 'L' or cmd == 'R':
batches.append((t, y, cmd, z))
else: # 'C' query
T = t
yq = y
zq = z
res = 0
for (t0, y0, dir, cnt) in batches:
if t0 > T:
continue
delta = T - t0
pos = None
if dir == 'L':
if delta <= y0:
pos = y0 - delta
else:
s = delta - y0
r = (s - 1) % (2 * N)
if r < N:
pos = r
else:
pos = 2 * N - r - 1
else: # 'R'
if delta <= (N - 1 - y0):
pos = y0 + delta
else:
s = delta - (N - 1 - y0)
r = (s - 1) % (2 * N)
if r < N:
pos = (N - 1) - r
else:
pos = r - N
if pos is not None and yq <= pos < zq:
res += cnt
print(res)
if __name__ == "__main__":
main()
gew1fw