結果
問題 | No.1053 ゲーミング棒 |
ユーザー |
![]() |
提出日時 | 2022-05-21 15:58:58 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 174 ms / 2,000 ms |
コード長 | 590 bytes |
コンパイル時間 | 287 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 138,904 KB |
最終ジャッジ日時 | 2024-09-20 11:52:43 |
合計ジャッジ時間 | 4,330 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 34 |
ソースコード
from collections import defaultdict, deque d = defaultdict(deque) N = int(input()) A = list(map(int, input().split())) A += A l, r = 0, 0 while l < N: while r < N+l: if (len(d[A[r]])>0 and d[A[r]][-1] == r-1) or len(d[A[r]])==0: d[A[r]].append(r) else: for i in range(l, r): d[A[i]].popleft() l = r if l >= N: break r -= 1 r += 1 if r-l == N: if l == 0: print(0) exit() else: print(1) exit() print(-1)