結果
問題 | No.2246 1333-like Number |
ユーザー |
![]() |
提出日時 | 2025-03-20 21:19:01 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,031 bytes |
コンパイル時間 | 386 ms |
コンパイル使用メモリ | 81,924 KB |
実行使用メモリ | 77,000 KB |
最終ジャッジ日時 | 2025-03-20 21:20:05 |
合計ジャッジ時間 | 4,728 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 1 TLE * 1 -- * 22 |
ソースコード
import heapqdef main():N = int(input())heap = []# Generate all possible (a, b) pairs with a < b and push their initial values into the heapfor a in range(1, 10):for b in range(a + 1, 10):initial_num = str(10 * a + b)num_tuple = (len(initial_num),) + tuple(map(int, initial_num))heapq.heappush(heap, (num_tuple, a, b, 0))current_count = 0result = ""while heap:num_tuple, a, b, c = heapq.heappop(heap)current_count += 1if current_count == N:# Convert the tuple back to the string representationresult = ''.join(map(str, num_tuple[1:]))break# Generate the next number by appending b to the current numbernew_num_str = ''.join(map(str, num_tuple[1:])) + str(b)new_num_tuple = (len(new_num_str),) + tuple(map(int, new_num_str))heapq.heappush(heap, (new_num_tuple, a, b, c + 1))print(result)if __name__ == "__main__":main()