183512025-10-21 07:29:06szabelrSzínezéscpp17Wrong answer 11/50428ms3476 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++;
        }else
        {
            if(vhely==1 and golyo[2]!=golyo[1] and golyo[n]!=golyo[1])
                v--;
            else if(vhely==n and golyo[n]!=golyo[n-1] and golyo[n]!=golyo[1])
                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/23ms320 KiB
11Accepted3/3411ms3456 KiB
12Wrong answer0/3428ms3332 KiB
13Wrong answer0/3423ms3388 KiB
14Accepted3/3409ms3416 KiB
15Accepted3/3400ms3268 KiB
16Wrong answer0/3418ms3348 KiB
17Wrong answer0/3419ms3268 KiB
18Wrong answer0/3402ms3476 KiB
19Wrong answer0/3418ms3272 KiB
20Wrong answer0/3402ms3372 KiB