Submission #66939973


Source Code Expand

#include <bits/stdc++.h>

using namespace std;


void solve(){
  int n, q;
  cin >> n >> q;
  int cnt = 0;
  vector<int> color(n + 2, 0);
  while(q--){
    int a;
    cin >> a;
    if(color[a] == 0){
      if(color[a - 1] == 1 && color[a + 1] == 1){
        cnt--;
      }else if(color[a - 1] == 0 && color[a + 1] == 0){
        cnt++;
      }
      color[a] = 1;
    }else{
      if(color[a - 1] == 1 && color[a + 1] == 1){
        cnt++;
      }else if(color[a - 1] == 0 && color[a + 1] == 0){
        cnt--;
      }
      color[a] = 0;
    }
    cout << cnt << endl;
  }
}

int main(){ 
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << showpoint << setprecision(10);

  int T = 1;
  //cin >> T;
  while(T--){
    solve();
  }
}

Submission Info

Submission Time
Task C - Black Intervals
User katalonecfly
Language C++ 20 (gcc 12.2)
Score 350
Code Size 793 Byte
Status AC
Exec Time 512 ms
Memory 5680 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 350 / 350
Status
AC × 3
AC × 29
Set Name Test Cases
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
Case Name Status Exec Time Memory
example_00.txt AC 1 ms 3592 KiB
example_01.txt AC 1 ms 3412 KiB
example_02.txt AC 1 ms 3408 KiB
hand_00.txt AC 486 ms 4824 KiB
hand_01.txt AC 484 ms 5112 KiB
hand_02.txt AC 492 ms 5680 KiB
hand_03.txt AC 480 ms 4876 KiB
hand_04.txt AC 1 ms 3412 KiB
hand_05.txt AC 483 ms 3520 KiB
random_00.txt AC 493 ms 3544 KiB
random_01.txt AC 488 ms 5136 KiB
random_02.txt AC 510 ms 4324 KiB
random_03.txt AC 492 ms 3400 KiB
random_04.txt AC 493 ms 3616 KiB
random_05.txt AC 491 ms 3540 KiB
random_06.txt AC 496 ms 3416 KiB
random_07.txt AC 493 ms 3500 KiB
random_08.txt AC 498 ms 4068 KiB
random_09.txt AC 494 ms 4360 KiB
random_10.txt AC 495 ms 3436 KiB
random_11.txt AC 493 ms 3492 KiB
random_12.txt AC 512 ms 4268 KiB
random_13.txt AC 495 ms 3468 KiB
random_14.txt AC 496 ms 3528 KiB
random_15.txt AC 491 ms 3500 KiB
random_16.txt AC 491 ms 3388 KiB
random_17.txt AC 511 ms 4388 KiB
random_18.txt AC 487 ms 3476 KiB
random_19.txt AC 494 ms 3564 KiB