結果
| 問題 | 
                            No.2246 1333-like Number
                             | 
                    
| コンテスト | |
| ユーザー | 
                             lam6er
                         | 
                    
| 提出日時 | 2025-04-15 23:11:47 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 935 ms / 2,000 ms | 
| コード長 | 639 bytes | 
| コンパイル時間 | 365 ms | 
| コンパイル使用メモリ | 82,140 KB | 
| 実行使用メモリ | 76,348 KB | 
| 最終ジャッジ日時 | 2025-04-15 23:14:09 | 
| 合計ジャッジ時間 | 14,081 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| 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 length of 2 for each pair
heap = []
for a, b in pairs:
    heapq.heappush(heap, (2, a, b))
# Process the first (n-1) elements
for _ in range(n - 1):
    length, a, b = heapq.heappop(heap)
    heapq.heappush(heap, (length + 1, a, b))
# The nth element is now the smallest in the heap
length, a, b = heapq.heappop(heap)
# Generate the resulting number as a string
result = str(a) + str(b) + (length - 2) * str(b)
print(result)
            
            
            
        
            
lam6er