結果

問題 No.1053 ゲーミング棒
ユーザー NoneNone
提出日時 2021-02-26 01:30:35
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 540 bytes
コンパイル時間 554 ms
コンパイル使用メモリ 82,472 KB
実行使用メモリ 117,344 KB
最終ジャッジ日時 2024-04-09 05:27:13
合計ジャッジ時間 3,766 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
54,104 KB
testcase_01 AC 41 ms
55,128 KB
testcase_02 AC 42 ms
54,516 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 41 ms
54,572 KB
testcase_06 AC 42 ms
54,740 KB
testcase_07 AC 42 ms
54,060 KB
testcase_08 AC 42 ms
54,312 KB
testcase_09 AC 42 ms
54,368 KB
testcase_10 AC 42 ms
55,196 KB
testcase_11 AC 41 ms
53,788 KB
testcase_12 AC 40 ms
53,976 KB
testcase_13 AC 41 ms
53,696 KB
testcase_14 AC 42 ms
54,380 KB
testcase_15 AC 41 ms
53,848 KB
testcase_16 AC 42 ms
54,040 KB
testcase_17 AC 42 ms
55,316 KB
testcase_18 AC 42 ms
55,580 KB
testcase_19 AC 41 ms
55,256 KB
testcase_20 AC 41 ms
54,628 KB
testcase_21 AC 41 ms
55,300 KB
testcase_22 AC 40 ms
54,120 KB
testcase_23 AC 124 ms
117,152 KB
testcase_24 AC 126 ms
115,500 KB
testcase_25 AC 127 ms
117,200 KB
testcase_26 WA -
testcase_27 AC 41 ms
54,220 KB
testcase_28 AC 41 ms
53,940 KB
testcase_29 AC 41 ms
54,244 KB
testcase_30 AC 62 ms
79,768 KB
testcase_31 AC 61 ms
80,544 KB
testcase_32 AC 60 ms
79,832 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 63 ms
81,008 KB
testcase_36 AC 62 ms
80,932 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)); 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