結果
| 問題 |
No.2246 1333-like Number
|
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-04-15 23:08:50 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 1,049 ms / 2,000 ms |
| コード長 | 695 bytes |
| コンパイル時間 | 390 ms |
| コンパイル使用メモリ | 82,068 KB |
| 実行使用メモリ | 76,460 KB |
| 最終ジャッジ日時 | 2025-04-15 23:11:17 |
| 合計ジャッジ時間 | 15,461 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 24 |
ソースコード
import heapq
n = int(input())
# Generate all valid (a, b) pairs where a < b
pairs = []
for a in range(1, 10):
for b in range(a + 1, 10):
pairs.append((a, b))
# Initialize the heap with the initial elements (c=0)
heap = []
for a, b in pairs:
heapq.heappush(heap, (2, a, b, 0)) # (length, a, b, c)
current_step = 0
result = None
while heap:
length, a, b, c = heapq.heappop(heap)
current_step += 1
if current_step == n:
# Construct the result string
result = str(a) + str(b) + str(b) * c
break
# Push the next element in this (a, b) sequence
new_length = length + 1
heapq.heappush(heap, (new_length, a, b, c + 1))
print(result)
lam6er