結果

問題 No.1053 ゲーミング棒
ユーザー NoneNone
提出日時 2021-02-26 01:40:55
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 91 ms / 2,000 ms
コード長 534 bytes
コンパイル時間 179 ms
コンパイル使用メモリ 82,128 KB
実行使用メモリ 109,032 KB
最終ジャッジ日時 2024-04-09 14:09:48
合計ジャッジ時間 3,490 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
53,564 KB
testcase_01 AC 40 ms
53,692 KB
testcase_02 AC 41 ms
54,292 KB
testcase_03 AC 42 ms
53,792 KB
testcase_04 AC 40 ms
54,212 KB
testcase_05 AC 40 ms
54,104 KB
testcase_06 AC 40 ms
54,248 KB
testcase_07 AC 41 ms
53,492 KB
testcase_08 AC 40 ms
54,372 KB
testcase_09 AC 39 ms
55,136 KB
testcase_10 AC 40 ms
54,180 KB
testcase_11 AC 40 ms
53,780 KB
testcase_12 AC 40 ms
54,976 KB
testcase_13 AC 40 ms
53,928 KB
testcase_14 AC 41 ms
54,240 KB
testcase_15 AC 41 ms
54,480 KB
testcase_16 AC 42 ms
54,776 KB
testcase_17 AC 40 ms
54,000 KB
testcase_18 AC 40 ms
53,636 KB
testcase_19 AC 40 ms
53,668 KB
testcase_20 AC 40 ms
54,064 KB
testcase_21 AC 41 ms
54,192 KB
testcase_22 AC 40 ms
54,104 KB
testcase_23 AC 91 ms
108,556 KB
testcase_24 AC 90 ms
108,868 KB
testcase_25 AC 90 ms
109,032 KB
testcase_26 AC 89 ms
108,996 KB
testcase_27 AC 40 ms
54,116 KB
testcase_28 AC 41 ms
54,176 KB
testcase_29 AC 42 ms
53,780 KB
testcase_30 AC 59 ms
81,196 KB
testcase_31 AC 60 ms
80,764 KB
testcase_32 AC 61 ms
80,012 KB
testcase_33 AC 61 ms
80,276 KB
testcase_34 AC 59 ms
80,580 KB
testcase_35 AC 60 ms
82,060 KB
testcase_36 AC 62 ms
82,140 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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)
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)
0