結果

問題 No.2929 Miracle Branch
ユーザー 学ぶマン学ぶマン
提出日時 2024-10-14 13:49:20
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,256 bytes
コンパイル時間 218 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 85,376 KB
最終ジャッジ日時 2024-10-14 13:49:32
合計ジャッジ時間 12,085 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
52,096 KB
testcase_01 AC 39 ms
52,480 KB
testcase_02 AC 43 ms
57,472 KB
testcase_03 AC 42 ms
52,608 KB
testcase_04 AC 40 ms
52,608 KB
testcase_05 AC 39 ms
52,608 KB
testcase_06 AC 40 ms
52,736 KB
testcase_07 AC 40 ms
52,736 KB
testcase_08 AC 41 ms
52,864 KB
testcase_09 AC 40 ms
52,480 KB
testcase_10 AC 40 ms
52,736 KB
testcase_11 AC 42 ms
52,736 KB
testcase_12 AC 52 ms
52,604 KB
testcase_13 AC 41 ms
52,608 KB
testcase_14 AC 40 ms
52,352 KB
testcase_15 AC 39 ms
52,736 KB
testcase_16 AC 40 ms
52,736 KB
testcase_17 AC 40 ms
52,224 KB
testcase_18 AC 64 ms
68,608 KB
testcase_19 AC 63 ms
69,376 KB
testcase_20 AC 64 ms
72,064 KB
testcase_21 AC 70 ms
76,088 KB
testcase_22 AC 39 ms
53,120 KB
testcase_23 AC 74 ms
76,160 KB
testcase_24 AC 95 ms
78,592 KB
testcase_25 AC 69 ms
76,256 KB
testcase_26 AC 52 ms
63,232 KB
testcase_27 AC 57 ms
65,280 KB
testcase_28 AC 43 ms
57,984 KB
testcase_29 AC 43 ms
57,600 KB
testcase_30 AC 43 ms
57,472 KB
testcase_31 AC 42 ms
57,984 KB
testcase_32 AC 43 ms
57,344 KB
testcase_33 WA -
testcase_34 AC 165 ms
84,992 KB
testcase_35 AC 157 ms
84,864 KB
testcase_36 WA -
testcase_37 AC 163 ms
84,992 KB
testcase_38 AC 157 ms
85,376 KB
testcase_39 AC 160 ms
84,992 KB
testcase_40 AC 157 ms
84,992 KB
testcase_41 AC 162 ms
84,992 KB
testcase_42 AC 165 ms
84,992 KB
testcase_43 AC 139 ms
84,680 KB
testcase_44 AC 147 ms
84,932 KB
testcase_45 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

inf = 1<<60
X = int(input())
if X == 1:
    print(2)
    print(1, 2)
    exit(print('b', 'g'))

limit = 2*10**5
def prime_factorize(n):
    a = []
    while n % 4 == 0:
        a.append(4)
        n //= 4
    if n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        # limit を超えるような素因数は不適格
        if f >= limit:
            return [inf]

        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

prime_factors = prime_factorize(X)

# limit 以上な素因数が含まれている場合は 実現できない
for prime in prime_factors:
    if prime >= limit:
        exit(print(-1))

# 茶色から採番
N = len(prime_factors) # 1 ~ N

# 緑色の個数
M = sum(prime_factors)

# 全部の頂点数
V = N + M
print(V)

# 茶色同士を連結するedge
# 1 と 2
# ...
# N - 1 と N
for i in range(1, N):
    print(i, i + 1)

# 各茶色頂点i と緑頂点を連結するedge
cnt = N + 1 # から採番
for i in range(1, N + 1):
    # メンバー数は prime_factors[i - 1]
    for j in range(prime_factors[i - 1]):
        print(i, cnt)
        cnt += 1

color = ['b'] * N + ['g'] * M
print(*color)
0