結果
問題 | No.2929 Miracle Branch |
ユーザー | ntuda |
提出日時 | 2024-10-13 21:05:17 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,052 bytes |
コンパイル時間 | 217 ms |
コンパイル使用メモリ | 82,048 KB |
実行使用メモリ | 80,896 KB |
最終ジャッジ日時 | 2024-10-13 21:05:29 |
合計ジャッジ時間 | 6,726 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 37 ms
57,088 KB |
testcase_01 | AC | 36 ms
51,712 KB |
testcase_02 | AC | 42 ms
58,496 KB |
testcase_03 | TLE | - |
testcase_04 | TLE | - |
testcase_05 | -- | - |
testcase_06 | -- | - |
testcase_07 | -- | - |
testcase_08 | -- | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
testcase_33 | -- | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
testcase_36 | -- | - |
testcase_37 | -- | - |
testcase_38 | -- | - |
testcase_39 | -- | - |
testcase_40 | -- | - |
testcase_41 | -- | - |
testcase_42 | -- | - |
testcase_43 | -- | - |
testcase_44 | -- | - |
testcase_45 | -- | - |
ソースコード
X = int(input()) INF = 2 * 10 ** 5 def make_divisors(n): divisors = [] # 必要に応じてsetにしても良いかも i = 1 while i <= INF and i ** 2 <= n: if n % i == 0: divisors.append(i) i += 1 return divisors condition = [] ans = INF + 10 # 茶色1個 if X + 1 < INF: ans = X + 1 condition = (1, (X,)) # 茶色2個 D = make_divisors(X) for d in D: tmp = (2 + d + X // d) if ans > tmp: ans = tmp condition = (2, (d, X // d)) # 茶色3個 D1 = make_divisors(X) for d1 in D1: D2 = make_divisors(X // d1) for d2 in D2: tmp = 3 + d1 + d2 + X // d1 // d2 if ans > tmp: ans = tmp condition = (3, (d1, d2, X // d1 // d2)) if ans > INF: print(-1) exit() b, D = condition UV = [] tmp = b for i in range(b): if i > 0: UV.append((0, i)) for d in range(D[i]): UV.append((i, tmp)) tmp += 1 else: print(ans) for u, v in UV: print(u + 1, v + 1) C = ["b"] * b + ["g"] * (ans - b) print(*C)