結果
問題 |
No.1053 ゲーミング棒
|
ユーザー |
|
提出日時 | 2021-02-26 01:25:40 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 536 bytes |
コンパイル時間 | 432 ms |
コンパイル使用メモリ | 82,796 KB |
実行使用メモリ | 115,072 KB |
最終ジャッジ日時 | 2024-10-01 17:00:54 |
合計ジャッジ時間 | 4,190 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 WA * 8 |
ソースコード
def deg(A): """ 連続して続く文字を圧縮する(※Counterではない) [1,1,1,2,2,2,3] -> [(1,3),(2,3),(3,1)] """ res=[] a0, cnt=A[0], 1 for a in A[1:]: if a!=a0: res.append((a0,cnt)); cnt=1 else: cnt+=1 a0=a res.append((a0,cnt)) return res from collections import Counter N=int(input()) A=list(map(int, input().split())) c=Counter(A) d=deg(A) for a,cnt in d[1:-1]: if c[a]>=2: print(-1) exit() if A[0]==A[-1]: print(1) else: print(0)