結果
| 問題 |
No.151 セグメントフィッシング
|
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 18:49:33 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,797 bytes |
| コンパイル時間 | 252 ms |
| コンパイル使用メモリ | 82,088 KB |
| 実行使用メモリ | 85,712 KB |
| 最終ジャッジ日時 | 2025-06-12 18:49:56 |
| 合計ジャッジ時間 | 20,808 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 18 WA * 1 |
ソースコード
import sys
def main():
input = sys.stdin.read().split()
ptr = 0
N = int(input[ptr])
ptr += 1
Q = int(input[ptr])
ptr += 1
groups = []
current_time = 0
for _ in range(Q):
current_time += 1
x = input[ptr]
ptr += 1
y = int(input[ptr])
ptr += 1
z = int(input[ptr])
ptr += 1
if x == 'L' or x == 'R':
groups.append((current_time, x, y, z))
else:
# Query type 'C'
# y is the start, z is the end of interval [y, z)
count = 0
t = current_time
for group in groups:
t0, dir, x_pos, z_count = group
s = t - t0
if s < 0:
continue
if dir == 'L':
if s <= x_pos:
pos = x_pos - s
else:
s_prime = s - (x_pos + 1)
cycle = 2 * (N - 1)
s_mod = s_prime % cycle
if s_mod < (N - 1):
pos = s_mod
else:
pos = 2 * (N - 1) - s_mod
else:
if s <= (N - 1 - x_pos):
pos = x_pos + s
else:
s_prime = s - (N - x_pos)
cycle = 2 * (N - 1)
s_mod = s_prime % cycle
if s_mod < (N - 1):
pos = (N - 1) - s_mod
else:
pos = s_mod - (N - 1) - 1
if y <= pos < z:
count += z_count
print(count)
if __name__ == "__main__":
main()
gew1fw