提出 #66960478


ソースコード 拡げる

#include <bits/stdc++.h>
using namespace std;

int main(){
    int N, Q;
    cin >> N >> Q;
    vector<int> a(N+2, 0);
    long long cnt = 0;
    while(Q--){
        int x;
        cin >> x;
        int L = a[x-1], C = a[x], R = a[x+1];
        int delta = 0;
        if(C == 0){
            if(L == 0 && R == 0) delta = +1;
            else if(L == 1 && R == 1) delta = -1;
        } else {
            if(L == 0 && R == 0) delta = -1;
            else if(L == 1 && R == 1) delta = +1;
        }
        cnt += delta;
        a[x] ^= 1;
        cout << cnt << "\n";
    }
    return 0;
}

提出情報

提出日時
問題 C - Black Intervals
ユーザ Naman____17
言語 C++ 17 (Clang 16.0.6)
得点 350
コード長 615 Byte
結果 AC
実行時間 618 ms
メモリ 5576 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 4 ms 3460 KiB
example_01.txt AC 1 ms 3444 KiB
example_02.txt AC 1 ms 3456 KiB
hand_00.txt AC 577 ms 4784 KiB
hand_01.txt AC 575 ms 4900 KiB
hand_02.txt AC 583 ms 5576 KiB
hand_03.txt AC 536 ms 4904 KiB
hand_04.txt AC 1 ms 3480 KiB
hand_05.txt AC 534 ms 3452 KiB
random_00.txt AC 572 ms 3556 KiB
random_01.txt AC 575 ms 4984 KiB
random_02.txt AC 603 ms 4340 KiB
random_03.txt AC 566 ms 3640 KiB
random_04.txt AC 567 ms 3476 KiB
random_05.txt AC 565 ms 3392 KiB
random_06.txt AC 576 ms 3440 KiB
random_07.txt AC 570 ms 3564 KiB
random_08.txt AC 579 ms 3992 KiB
random_09.txt AC 618 ms 4436 KiB
random_10.txt AC 575 ms 3440 KiB
random_11.txt AC 571 ms 3456 KiB
random_12.txt AC 598 ms 4288 KiB
random_13.txt AC 578 ms 3404 KiB
random_14.txt AC 578 ms 3588 KiB
random_15.txt AC 569 ms 3504 KiB
random_16.txt AC 568 ms 3472 KiB
random_17.txt AC 604 ms 4332 KiB
random_18.txt AC 558 ms 3468 KiB
random_19.txt AC 576 ms 3536 KiB