結果

問題 No.2929 Miracle Branch
ユーザー Kude
提出日時 2024-10-12 15:39:54
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 185 ms / 2,000 ms
コード長 772 bytes
コンパイル時間 215 ms
コンパイル使用メモリ 82,344 KB
実行使用メモリ 108,304 KB
最終ジャッジ日時 2024-10-12 15:40:06
合計ジャッジ時間 10,011 ms
ジャッジサーバーID
(参考情報)
judge / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #

x = int(input())
if x == 1:
    print('''2
1 2
b g''')
    exit()
# 2:3
# 4:5
# 8:9
d = []
for p in range(2, 2 * 10 ** 5):
    cnt = 0
    while x % p == 0:
        x //= p
        cnt += 1
    while cnt:
        if p == 2 and cnt >= 2:
            d.append(4)
            cnt -= 2
        else:
            d.append(p)
            cnt -= 1
n = sum(d) + len(d)
if x != 1 or n > 2 * 10 ** 5:
    print(-1)
    exit()
last = -1
id = 0
col = []
es = []
for x in d:
    if last != -1:
        es.append((last, id))
    last = id
    col.append('b')
    for i in range(x):
        es.append((last, last + 1 + i))
        col.append('g')
    id += 1 + x

assert id == n and len(es) == n - 1 and len(col) == n
print(n)
for u, v in es:
    print(u + 1, v + 1)
print(' '.join(col))
0