結果
| 問題 |
No.1053 ゲーミング棒
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-02-26 01:40:14 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 543 bytes |
| コンパイル時間 | 210 ms |
| コンパイル使用メモリ | 82,432 KB |
| 実行使用メモリ | 115,840 KB |
| 最終ジャッジ日時 | 2024-10-01 17:19:55 |
| 合計ジャッジ時間 | 3,759 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 3 |
| other | WA * 34 |
ソースコード
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=1
else: cnt+=1
a0=a
res.append(a0)
return res
from collections import Counter
N=int(input())
A=list(map(int, input().split()))
B=deg(A)
c=Counter(B)
print(c)
for a in B[1:-1]:
if c[a]>=2:
print(-1)
exit()
if A[0]==A[-1] and len(c)>=2:
print(1)
else:
print(0)