提出 #66945693


ソースコード 拡げる

N,Q=map(int,input().split())
A=list(map(int,input().split()))
L=[0]*N
res=0
if N==1:
    for i in range(Q):
        print((i+1)%2)
    quit()
for i in A:
    if i!=1:
        if i!=N:
            if L[i]==L[i-2]==0:
                if L[i-1]==0:
                    res+=1
                else:
                    res-=1
            if L[i]==L[i-2]==1:
                if L[i-1]==0:
                    res-=1
                else:
                    res+=1
        else:
            if L[-2]==0==L[-1]:
                res+=1
            elif L[-1]==1 and L[-2]==0:
                res-=1
        

    else:
        if L[1]==0==L[0]:
            res+=1
        elif L[0]==1 and L[1]==0:
            res-=1
    L[i-1]^=1
    #print(L)
    print(res)


提出情報

提出日時
問題 C - Black Intervals
ユーザ ryuuichi
言語 Python (PyPy 3.10-v7.3.12)
得点 350
コード長 793 Byte
結果 AC
実行時間 184 ms
メモリ 173180 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 350 / 350
結果
AC × 3
AC × 29
セット名 テストケース
Sample example_00.txt, example_01.txt, example_02.txt
All example_00.txt, example_01.txt, example_02.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt
ケース名 結果 実行時間 メモリ
example_00.txt AC 53 ms 76296 KiB
example_01.txt AC 54 ms 76432 KiB
example_02.txt AC 54 ms 76292 KiB
hand_00.txt AC 141 ms 156052 KiB
hand_01.txt AC 140 ms 155932 KiB
hand_02.txt AC 154 ms 156392 KiB
hand_03.txt AC 139 ms 173180 KiB
hand_04.txt AC 53 ms 76612 KiB
hand_05.txt AC 161 ms 173104 KiB
random_00.txt AC 168 ms 146000 KiB
random_01.txt AC 141 ms 156236 KiB
random_02.txt AC 182 ms 154204 KiB
random_03.txt AC 173 ms 145952 KiB
random_04.txt AC 173 ms 145804 KiB
random_05.txt AC 173 ms 145844 KiB
random_06.txt AC 173 ms 149960 KiB
random_07.txt AC 165 ms 145616 KiB
random_08.txt AC 166 ms 154164 KiB
random_09.txt AC 161 ms 155232 KiB
random_10.txt AC 170 ms 149536 KiB
random_11.txt AC 172 ms 146028 KiB
random_12.txt AC 183 ms 153912 KiB
random_13.txt AC 176 ms 149748 KiB
random_14.txt AC 175 ms 149768 KiB
random_15.txt AC 166 ms 145892 KiB
random_16.txt AC 176 ms 145728 KiB
random_17.txt AC 182 ms 154552 KiB
random_18.txt AC 184 ms 142908 KiB
random_19.txt AC 170 ms 149876 KiB