結果
問題 | No.1242 高橋君とすごろく |
ユーザー | FromBooska |
提出日時 | 2023-09-05 12:24:04 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,378 bytes |
コンパイル時間 | 312 ms |
コンパイル使用メモリ | 87,044 KB |
実行使用メモリ | 81,560 KB |
最終ジャッジ日時 | 2023-09-05 12:24:13 |
合計ジャッジ時間 | 4,912 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 75 ms
75,980 KB |
testcase_01 | AC | 75 ms
71,444 KB |
testcase_02 | AC | 77 ms
71,200 KB |
testcase_03 | AC | 79 ms
71,420 KB |
testcase_04 | AC | 76 ms
71,160 KB |
testcase_05 | AC | 75 ms
71,176 KB |
testcase_06 | AC | 74 ms
71,168 KB |
testcase_07 | AC | 74 ms
71,000 KB |
testcase_08 | AC | 74 ms
71,328 KB |
testcase_09 | AC | 73 ms
71,496 KB |
testcase_10 | TLE | - |
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 | -- | - |
ソースコード
# すごろくだしゴールから戻っていくか # そのマスがOKかどうかの判定、1or6, 2or5, 3or4先のすべてが止まれればOKマス # 戻っていってスタートの1がOKならYes # コンセプトはそれでいいがN10**18は巨大すぎる # ただしK<100なのでここは相当非効率でも間に合うと思ったがマルチセットでもTLE # heapでやる、存在確認用のセットも使う N, K = map(int, input().split()) A = list(map(int, input().split())) A_set = set(A) from heapq import * H = [-a for a in A] heapify(H) ans = 'Yes' while H: largest = -heappop(H) if largest == 1: ans = 'No' A_set.discard(largest) if largest-6 >= 1 and largest-5 in A_set and largest-6 not in A_set: heappush(H, -(largest-6)) A_set.add(largest-6) if largest-5 >= 1 and largest-3 in A_set and largest-5 not in A_set: heappush(H, -(largest-5)) A_set.add(largest-5) # このケースだけは新たにNGが生まれうる if largest-6 >= 1 and largest-5 in A_set and largest-6 not in A_set: heappush(H, -(largest-6)) A_set.add(largest-6) if largest-4 >= 1 and largest-1 in A_set and largest-4 not in A_set: heappush(H, -(largest-4)) A_set.add(largest-4) #print('largest', largest, 'H', H, 'A_set', A_set) print(ans)