183502025-10-21 07:25:09szabelrSzínezéscpp17Wrong answer 11/50416ms3356 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]){
            if(vban==0){
                v++;
                vban=1;
            }else
            vban=0;
        }

    }

    cout<<v<<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<<endl;
    }

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base11/50
1Accepted0/01ms316 KiB
2Accepted0/03ms316 KiB
3Accepted2/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
11Accepted3/3402ms3328 KiB
12Wrong answer0/3416ms3328 KiB
13Wrong answer0/3402ms3348 KiB
14Accepted3/3412ms3328 KiB
15Accepted3/3402ms3268 KiB
16Wrong answer0/3416ms3268 KiB
17Wrong answer0/3402ms3356 KiB
18Wrong answer0/3409ms3268 KiB
19Wrong answer0/3414ms3268 KiB
20Wrong answer0/3389ms3268 KiB