結果
問題 |
No.1242 高橋君とすごろく
|
ユーザー |
![]() |
提出日時 | 2025-03-27 21:52:41 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,809 bytes |
コンパイル時間 | 364 ms |
コンパイル使用メモリ | 82,604 KB |
実行使用メモリ | 54,620 KB |
最終ジャッジ日時 | 2025-03-27 21:52:44 |
合計ジャッジ時間 | 2,667 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 22 WA * 2 |
ソースコード
from heapq import * Q = [] N, K = map(int, input().split()) A = [i - 1 for i in list(map(int, input().split()))] pa = 10 ** 18 + 10 X = [1] * 6 j = K - 1 i = K - 1 while i >= 0: if Q: if -Q[0] == A[i]: a = -heappop(Q) i -= 1 elif -Q[0] > A[i]: a = -heappop(Q) else: a = A[i] i -= 1 else: a = A[i] i -= 1 while i + 1 < j and A[j] - A[i + 1] >= 6: j -= 1 if i + 1 < j: for j2 in range(i + 2,j + 1): b = A[j2] for k in range(5,0,-2): if b - a == k or X[(a + k) % 6] == 0: c = a - (7 - k) // 2 if c >= 0: if X[c % 6] == 1: X[a % 6] = 0 X[(a + k) % 6] = 0 if X[c % 6] == 1: X[c % 6] = 0 heappush(Q,-c) for l in range(1,6): if c - l>= 0 and X[(c-l) % 6] == 0: heappush(Q,-(c-l)) #print(a, k, b,c,X) #print(i,X,Q) while Q: a = -heappop(Q) for k in range(5, 0, -2): if X[(a + k) % 6] == 0: c = a - (7 - k) // 2 if c >= 0: if X[c % 6] == 1: X[a % 6] = 0 X[(a + k) % 6] = 0 if X[c % 6] == 1: X[c % 6] = 0 heappush(Q,-c) for l in range(1, 6): if c - l >= 0 and X[(c - l) % 6] == 0: heappush(Q, -(c - l)) #print(a, k, b, c, X) #print(X) if X[0] == 0: print("No") else: print("Yes")