123542024-12-13 08:15:12KissCsongor777Színezéscpp17Accepted 50/50419ms3372 KiB
#include <iostream>

using namespace std;

int main()
{
    int n,q,a=1,x;
    cin>>n>>q;
    string H;
    cin>>H;
    H=' '+H;
    for(int i=1; i<=n-1; i++)
    {
       if(H[i]!=H[i+1])a++;

    }
    cout<<a/2<<endl;
    for(int i=1; i<=q; i++)
    {
        cin>>x;
        if(H[x]=='1')H[x]='0';else H[x]='1';
        if(x==1)if(H[2]==H[1])a--;else a++;
        else if(x==n)if(H[n-1]==H[n])a--;else a++;
        else {if(H[x-1]==H[x])a--;else a++;if(H[x]==H[x+1])a--;else a++;}

        cout<<a/2<<endl;
    }
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/01ms320 KiB
2Accepted0/03ms512 KiB
3Accepted2/21ms320 KiB
4Accepted2/21ms320 KiB
5Accepted3/31ms320 KiB
6Accepted3/31ms320 KiB
7Accepted3/33ms320 KiB
8Accepted3/33ms320 KiB
9Accepted2/23ms320 KiB
10Accepted2/23ms500 KiB
11Accepted3/3418ms3196 KiB
12Accepted3/3418ms3364 KiB
13Accepted3/3405ms3372 KiB
14Accepted3/3405ms3188 KiB
15Accepted3/3400ms3332 KiB
16Accepted3/3402ms3332 KiB
17Accepted3/3418ms3188 KiB
18Accepted3/3411ms3172 KiB
19Accepted3/3402ms3332 KiB
20Accepted3/3419ms3332 KiB