79882024-01-12 09:42:48BenedekMartonSzínezéscpp17Wrong answer 0/50476ms4788 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 << 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-1)
        {
            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 << endl;
        g[v]=!g[v];
    }
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base0/50
1Wrong answer0/03ms1744 KiB
2Wrong answer0/04ms1920 KiB
3Wrong answer0/23ms1996 KiB
4Wrong answer0/23ms2124 KiB
5Wrong answer0/33ms2332 KiB
6Wrong answer0/33ms2588 KiB
7Wrong answer0/34ms2760 KiB
8Wrong answer0/34ms2976 KiB
9Wrong answer0/24ms3224 KiB
10Wrong answer0/24ms3396 KiB
11Wrong answer0/3294ms3800 KiB
12Wrong answer0/3432ms3796 KiB
13Wrong answer0/3476ms4112 KiB
14Wrong answer0/3289ms4360 KiB
15Wrong answer0/3416ms4200 KiB
16Wrong answer0/3442ms4480 KiB
17Wrong answer0/3465ms4420 KiB
18Wrong answer0/3282ms4460 KiB
19Wrong answer0/3367ms4544 KiB
20Wrong answer0/3284ms4788 KiB