183542025-10-21 07:45:35szabelrSzínezéscpp17Accepted 50/50412ms3456 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(golyo[vhely-1]==golyo[vhely] and (vhely-1)!=0){
            v--;
        }

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

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

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/01ms316 KiB
2Accepted0/03ms768 KiB
3Accepted2/21ms316 KiB
4Accepted2/21ms316 KiB
5Accepted3/31ms316 KiB
6Accepted3/31ms316 KiB
7Accepted3/33ms508 KiB
8Accepted3/33ms316 KiB
9Accepted2/23ms316 KiB
10Accepted2/23ms508 KiB
11Accepted3/3409ms3436 KiB
12Accepted3/3398ms3424 KiB
13Accepted3/3407ms3412 KiB
14Accepted3/3398ms3400 KiB
15Accepted3/3397ms3264 KiB
16Accepted3/3409ms3332 KiB
17Accepted3/3411ms3268 KiB
18Accepted3/3397ms3456 KiB
19Accepted3/3412ms3268 KiB
20Accepted3/3395ms3268 KiB