183532025-10-21 07:37:47szabelrSzínezéscpp17Wrong answer 0/50414ms3428 KiB
#include <iostream>

using namespace std;
long long golyo[200001];
int main()
{
    long long n,q,v=0,vban=0,vhely;
    string x;
    cin>>n>>q;
    cin>>x;
    for(int i=1; i<=n; i++){
        if (x[i-1] == '0') {
            golyo[i] = 0;
        }
        else
            golyo[i] = 1;
    }
    for(int i=2; i<=n; i++){
        if(golyo[i-1]!=golyo[i]){
            v++;
        }

    }

    cout<<(v+1)/2<<endl;
    for(int i=1; i<=q; i++){
        cin>>vhely;

        if(golyo[vhely]==1)
        {
            golyo[vhely]=0;

        }

        else
        {
            golyo[vhely]=1;

        }
        if(vhely!=n and vhely!=1){

        if(golyo[vhely-1]==golyo[vhely] and golyo[vhely+1]==golyo[vhely])
            v--;
        else if(golyo[vhely-1]!=golyo[vhely]  and golyo[vhely+1]!=golyo[vhely] )
            v++;
        }

        cout<<(v+1)/2<<endl;
    }

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base0/50
1Accepted0/01ms540 KiB
2Wrong answer0/03ms316 KiB
3Wrong answer0/21ms316 KiB
4Wrong answer0/21ms316 KiB
5Wrong answer0/31ms316 KiB
6Wrong answer0/31ms316 KiB
7Wrong answer0/33ms316 KiB
8Wrong answer0/33ms316 KiB
9Wrong answer0/23ms316 KiB
10Wrong answer0/23ms316 KiB
11Wrong answer0/3407ms3356 KiB
12Wrong answer0/3405ms3428 KiB
13Wrong answer0/3412ms3292 KiB
14Wrong answer0/3414ms3412 KiB
15Wrong answer0/3407ms3384 KiB
16Wrong answer0/3407ms3264 KiB
17Wrong answer0/3412ms3356 KiB
18Wrong answer0/3405ms3344 KiB
19Wrong answer0/3363ms3268 KiB
20Wrong answer0/3360ms3268 KiB