結果

問題 No.1053 ゲーミング棒
ユーザー NoneNone
提出日時 2021-02-26 01:25:40
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 536 bytes
コンパイル時間 822 ms
コンパイル使用メモリ 82,376 KB
実行使用メモリ 115,140 KB
最終ジャッジ日時 2024-04-09 05:23:41
合計ジャッジ時間 4,338 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
54,192 KB
testcase_01 AC 41 ms
54,124 KB
testcase_02 AC 40 ms
54,412 KB
testcase_03 AC 40 ms
55,164 KB
testcase_04 AC 41 ms
54,440 KB
testcase_05 AC 42 ms
54,852 KB
testcase_06 WA -
testcase_07 AC 40 ms
54,508 KB
testcase_08 WA -
testcase_09 AC 39 ms
55,456 KB
testcase_10 AC 39 ms
54,020 KB
testcase_11 AC 40 ms
53,664 KB
testcase_12 AC 39 ms
54,344 KB
testcase_13 WA -
testcase_14 AC 40 ms
55,292 KB
testcase_15 AC 39 ms
54,652 KB
testcase_16 AC 39 ms
53,936 KB
testcase_17 AC 40 ms
54,504 KB
testcase_18 AC 41 ms
54,860 KB
testcase_19 AC 40 ms
53,496 KB
testcase_20 AC 40 ms
55,164 KB
testcase_21 AC 39 ms
53,664 KB
testcase_22 AC 40 ms
54,220 KB
testcase_23 AC 102 ms
115,140 KB
testcase_24 AC 102 ms
114,960 KB
testcase_25 AC 101 ms
114,800 KB
testcase_26 AC 101 ms
114,808 KB
testcase_27 WA -
testcase_28 AC 40 ms
54,220 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 64 ms
82,300 KB
testcase_32 AC 65 ms
82,220 KB
testcase_33 AC 63 ms
82,828 KB
testcase_34 AC 64 ms
83,548 KB
testcase_35 WA -
testcase_36 WA -
権限があれば一括ダウンロードができます

ソースコード

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