Submission #66939172


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
int m[5000005]; 
int x,y,da=0;
int main(){
	cin>>x>>y;
	for(int i=0;i<=x+1;i++) m[i]=0;
	for(int i=1;i<=y;i++){
		
		int a;
		cin>>a;
		//cout<<da<<" ";
		if(m[a]==0){
			if(m[a-1]==0&&m[a+1]==0){
				m[a]=1;
				da++;
			}
			else if(m[a-1]!=0&&m[a+1]!=0){
				da--;
				m[a]=1;
			}
			else m[a]=1;
		}
		else{
			if(m[a-1]==0&&m[a+1]==0){
				m[a]=0;
				da--;
			}
			else if(m[a-1]!=0&&m[a+1]!=0){
				da++;
				m[a]=0;
			}
			else m[a]=0;
		}
		cout<<da<<"\n";
	}
	return 0;
}

Submission Info

Submission Time
Task C - Black Intervals
User Fireflies
Language C++ 20 (gcc 12.2)
Score 350
Code Size 568 Byte
Status AC
Exec Time 593 ms
Memory 5612 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 3400 KiB
example_01.txt AC 1 ms 3512 KiB
example_02.txt AC 1 ms 3396 KiB
hand_00.txt AC 573 ms 5476 KiB
hand_01.txt AC 573 ms 5552 KiB
hand_02.txt AC 581 ms 5612 KiB
hand_03.txt AC 532 ms 5544 KiB
hand_04.txt AC 1 ms 3524 KiB
hand_05.txt AC 539 ms 3448 KiB
random_00.txt AC 574 ms 3652 KiB
random_01.txt AC 577 ms 5428 KiB
random_02.txt AC 592 ms 4440 KiB
random_03.txt AC 569 ms 3524 KiB
random_04.txt AC 566 ms 3596 KiB
random_05.txt AC 567 ms 3476 KiB
random_06.txt AC 578 ms 3540 KiB
random_07.txt AC 574 ms 3520 KiB
random_08.txt AC 579 ms 4416 KiB
random_09.txt AC 579 ms 4936 KiB
random_10.txt AC 580 ms 3792 KiB
random_11.txt AC 567 ms 3520 KiB
random_12.txt AC 591 ms 4360 KiB
random_13.txt AC 578 ms 3568 KiB
random_14.txt AC 584 ms 3832 KiB
random_15.txt AC 570 ms 3704 KiB
random_16.txt AC 566 ms 3536 KiB
random_17.txt AC 593 ms 4496 KiB
random_18.txt AC 557 ms 3480 KiB
random_19.txt AC 577 ms 3552 KiB