結果
| 問題 |
No.2246 1333-like Number
|
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-03-31 17:32:34 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 785 bytes |
| コンパイル時間 | 221 ms |
| コンパイル使用メモリ | 82,896 KB |
| 実行使用メモリ | 67,420 KB |
| 最終ジャッジ日時 | 2025-03-31 17:33:29 |
| 合計ジャッジ時間 | 4,528 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 1 TLE * 1 -- * 22 |
ソースコード
import heapq
def main():
N = int(input().strip())
heap = []
# Generate all possible (a, b) pairs where a < b
for a in range(1, 10):
for b in range(a + 1, 10):
s = f"{a}{b}"
# Push the tuple (length, string, a, b, c)
heapq.heappush(heap, (len(s), s, a, b, 0))
count = 0
result = ""
while heap:
current = heapq.heappop(heap)
length, s, a, b, c = current
count += 1
if count == N:
result = s
break
# Generate the next number by appending b
new_s = s + str(b)
new_length = length + 1
heapq.heappush(heap, (new_length, new_s, a, b, c + 1))
print(result)
if __name__ == "__main__":
main()
lam6er