結果

問題 No.1053 ゲーミング棒
ユーザー NoneNone
提出日時 2021-02-26 01:28:20
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 526 bytes
コンパイル時間 737 ms
コンパイル使用メモリ 82,468 KB
実行使用メモリ 117,448 KB
最終ジャッジ日時 2024-04-09 05:25:50
合計ジャッジ時間 4,141 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
53,552 KB
testcase_01 AC 43 ms
55,052 KB
testcase_02 AC 42 ms
53,548 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 43 ms
55,024 KB
testcase_06 AC 43 ms
55,676 KB
testcase_07 AC 44 ms
54,116 KB
testcase_08 AC 42 ms
55,116 KB
testcase_09 AC 42 ms
54,560 KB
testcase_10 AC 42 ms
54,064 KB
testcase_11 AC 42 ms
53,704 KB
testcase_12 AC 42 ms
54,280 KB
testcase_13 AC 42 ms
54,368 KB
testcase_14 AC 42 ms
53,980 KB
testcase_15 AC 42 ms
54,376 KB
testcase_16 AC 42 ms
53,820 KB
testcase_17 AC 42 ms
54,440 KB
testcase_18 AC 42 ms
55,344 KB
testcase_19 AC 43 ms
54,636 KB
testcase_20 AC 43 ms
54,740 KB
testcase_21 AC 43 ms
54,708 KB
testcase_22 AC 42 ms
54,524 KB
testcase_23 AC 128 ms
117,228 KB
testcase_24 AC 131 ms
117,448 KB
testcase_25 AC 128 ms
117,360 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 41 ms
53,704 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 63 ms
80,888 KB
testcase_32 AC 63 ms
80,356 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 63 ms
81,084 KB
testcase_36 AC 63 ms
80,892 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]:
    print(1)
else:
    print(0)
0