結果

問題 No.2597 Yet Another Topological Problem
ユーザー rin204
提出日時 2023-12-25 22:09:12
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 674 bytes
コンパイル時間 451 ms
コンパイル使用メモリ 82,220 KB
実行使用メモリ 98,688 KB
最終ジャッジ日時 2024-09-27 14:43:51
合計ジャッジ時間 22,363 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 47 WA * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

p, q = map(int, input().split())

if p == 1:
    print("Impossible")
    exit()

d = q // p
tot = d * (d + 1)
x = 240000 // tot
S = []
ud = "U"
rev = {"U": "D", "D": "U"}
for i in range(d, 0, -1):
    S.append(ud * i)
    S.append("R" * x * i)
    ud = rev[ud]
    S.append(ud * i)
for i in range(1, d + 1):
    S.append(ud * i)
    S.append("R" * x * i)
    ud = rev[ud]
    S.append(ud * i)

S = "".join(S)
x, y = 0, 0
XY = [(x, y)]
for s in S:
    if s == "U":
        y += 1
    elif s == "D":
        y -= 1
    elif s == "R":
        x += 1
    elif s == "L":
        x -= 1
    XY.append((x, y))


print("Possible")
print(len(XY) - 1)
for x, y in XY:
    print(x, y)
0