結果
| 問題 |
No.2045 Two Reflections
|
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 16:15:11 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,065 bytes |
| コンパイル時間 | 276 ms |
| コンパイル使用メモリ | 82,516 KB |
| 実行使用メモリ | 67,912 KB |
| 最終ジャッジ日時 | 2025-06-12 16:15:31 |
| 合計ジャッジ時間 | 2,450 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 WA * 7 |
ソースコード
import sys
import math
MOD = 998244353
def main():
N, p, q = map(int, sys.stdin.readline().split())
# Compute f[i] for each i
f = [0] * (N + 1) # 1-based indexing
for i in range(1, N + 1):
if i <= p:
j = p + 1 - i
if j >= (N - q + 1):
f[i] = (2 * N - q + 1) - j
else:
f[i] = j
else:
if i >= (N - q + 1):
f[i] = (2 * N - q + 1) - i
else:
f[i] = i
visited = [False] * (N + 1)
lcm = 1
for i in range(1, N + 1):
if not visited[i]:
current = i
cycle_length = 0
while not visited[current]:
visited[current] = True
current = f[current]
cycle_length += 1
if cycle_length > 0:
g = math.gcd(lcm, cycle_length)
lcm = (lcm // g) * cycle_length
# The answer is 2 * lcm mod MOD
answer = (2 * lcm) % MOD
print(answer)
if __name__ == "__main__":
main()
gew1fw