79472024-01-12 08:14:50BenedekMartonSzínezéscpp17Wrong answer 18/50514ms4828 KiB
#include <iostream>

using namespace std;

int main()
{
    int n, q, szk=1, v;
    cin >> n >> q;
    char c;
    bool g[n];
    cin.get();
    cin.get(c);
    g[0]=c-'0';
    for(int i=1; i<n; i++)
    {
        cin.get(c);
        g[i]=c-'0';
        if(g[i-1]!=g[i])
        {
            szk++;
        }
    }
    cout << szk/2 << endl;
    for(int i=0; i<q; i++)
    {
        cin >> v; v--;
        if(v==0)
        {
            if(g[1]!=g[0])
            {
                szk--;
                //cout << "k";
            }
            else
            {
                szk++;
                //cout << "h";
            }
        }
        else if(v==n)
        {
            if(g[n]!=g[n-1])
            {
                szk--;
                //cout << "c";
            }
            else
            {
                szk++;
                //cout << "a";
            }
        }
        else if(g[v-1]==g[v+1])
        {
            if(g[v]==g[v-1])
            {
                szk=szk+2;
                //cout << "b";
            }
            else
            {
                szk=szk-2;
                //cout << "p";
            }
        }
        cout << szk/2 << endl;
        g[v]=!g[v];
    }
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base18/50
1Accepted0/03ms1872 KiB
2Accepted0/04ms2132 KiB
3Accepted2/23ms2280 KiB
4Accepted2/23ms2496 KiB
5Accepted3/32ms2576 KiB
6Wrong answer0/33ms2856 KiB
7Accepted3/34ms2756 KiB
8Wrong answer0/34ms2876 KiB
9Accepted2/24ms2824 KiB
10Wrong answer0/24ms2952 KiB
11Wrong answer0/3474ms3484 KiB
12Wrong answer0/3377ms3672 KiB
13Wrong answer0/3437ms3632 KiB
14Accepted3/3300ms3884 KiB
15Accepted3/3490ms4100 KiB
16Wrong answer0/3472ms4056 KiB
17Wrong answer0/3512ms4356 KiB
18Wrong answer0/3421ms4272 KiB
19Wrong answer0/3421ms4524 KiB
20Wrong answer0/3514ms4828 KiB