結果
問題 |
No.151 セグメントフィッシング
|
ユーザー |
![]() |
提出日時 | 2025-04-09 20:56:08 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,250 bytes |
コンパイル時間 | 170 ms |
コンパイル使用メモリ | 82,352 KB |
実行使用メモリ | 87,820 KB |
最終ジャッジ日時 | 2025-04-09 20:57:11 |
合計ジャッジ時間 | 19,195 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 18 WA * 1 |
ソースコード
def main(): import sys input = sys.stdin.read().split() idx = 0 N = int(input[idx]) idx += 1 Q = int(input[idx]) idx += 1 queries = [] for _ in range(Q): cmd = input[idx] if cmd == 'C': y = int(input[idx+1]) z = int(input[idx+2]) queries.append((cmd, y, z)) idx += 3 else: y = int(input[idx+1]) z = int(input[idx+2]) queries.append((cmd, y, z)) idx += 3 L = N - 1 groups = [] current_time = 0 for query in queries: current_time += 1 if query[0] in ('L', 'R'): t0 = current_time y0 = query[1] direction = query[0] z = query[2] groups.append((t0, y0, direction, z)) else: y_start, y_end = query[1], query[2] count = 0 for (t0, y0, dir_, z) in groups: d = current_time - t0 if dir_ == 'R': steps_right = L - y0 if d <= steps_right: x = y0 + d else: rem = d - steps_right if rem == 0: x = L else: rem -= 1 if rem <= L: x = L - rem else: rem = (rem - 1) % (L + 1) x = L - rem else: steps_left = y0 if d <= steps_left: x = y0 - d else: rem = d - steps_left if rem == 0: x = 0 else: rem -= 1 if rem <= L: x = rem else: rem = (rem - 1) % (L + 1) x = rem if y_start <= x < y_end: count += z print(count) if __name__ == "__main__": main()