79862024-01-12 09:41:50BenedekMartonSzínezéscpp17Wrong answer 0/50509ms4224 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/03ms1876 KiB
2Wrong answer0/04ms2072 KiB
3Wrong answer0/23ms2280 KiB
4Wrong answer0/23ms2364 KiB
5Wrong answer0/33ms2504 KiB
6Wrong answer0/33ms2744 KiB
7Wrong answer0/34ms2800 KiB
8Wrong answer0/34ms2804 KiB
9Wrong answer0/24ms2928 KiB
10Wrong answer0/24ms3172 KiB
11Wrong answer0/3293ms3576 KiB
12Wrong answer0/3286ms3576 KiB
13Wrong answer0/3293ms3576 KiB
14Wrong answer0/3291ms3700 KiB
15Wrong answer0/3426ms4056 KiB
16Wrong answer0/3476ms3980 KiB
17Wrong answer0/3504ms3864 KiB
18Wrong answer0/3509ms3908 KiB
19Wrong answer0/3458ms4224 KiB
20Wrong answer0/3493ms4128 KiB