結果
| 問題 |
No.259 セグメントフィッシング+
|
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 12:53:23 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,562 bytes |
| コンパイル時間 | 292 ms |
| コンパイル使用メモリ | 82,176 KB |
| 実行使用メモリ | 120,960 KB |
| 最終ジャッジ日時 | 2025-06-12 12:55:02 |
| 合計ジャッジ時間 | 5,559 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 5 TLE * 1 -- * 17 |
ソースコード
def compute_left_pos(y0, delta, N):
effective = y0 - delta
if effective >= 0:
return effective
else:
effective = -effective - 1
cycles = effective // N
remainder = effective % N
if cycles % 2 == 0:
return remainder
else:
return (N - 1) - remainder
def compute_right_pos(y0, delta, N):
effective = y0 + delta
cycles = effective // N
remainder = effective % N
if cycles % 2 == 0:
return remainder
else:
return (N - 1) - remainder
def main():
import sys
input = sys.stdin.read().split()
ptr = 0
N = int(input[ptr])
ptr += 1
Q = int(input[ptr])
ptr += 1
fish = []
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':
fish.append((t, y, cmd, z))
elif cmd == 'C':
a = y
b = z
current_t = t
total = 0
for (t0, y0, direction, z_val) in fish:
if t0 > current_t:
continue
delta = current_t - t0
if direction == 'L':
pos = compute_left_pos(y0, delta, N)
else:
pos = compute_right_pos(y0, delta, N)
if a <= pos < b:
total += z_val
print(total)
if __name__ == '__main__':
main()
gew1fw