79912024-01-12 09:44:19BenedekMartonSzínezéscpp17Wrong answer 0/50503ms4252 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/04ms2224 KiB
3Wrong answer0/23ms2248 KiB
4Wrong answer0/23ms2496 KiB
5Wrong answer0/33ms2736 KiB
6Wrong answer0/33ms2916 KiB
7Wrong answer0/34ms3124 KiB
8Wrong answer0/34ms3176 KiB
9Wrong answer0/24ms3212 KiB
10Wrong answer0/24ms3184 KiB
11Wrong answer0/3293ms3612 KiB
12Wrong answer0/3287ms3620 KiB
13Wrong answer0/3296ms3504 KiB
14Wrong answer0/3287ms3760 KiB
15Wrong answer0/3293ms3720 KiB
16Wrong answer0/3503ms3720 KiB
17Wrong answer0/3472ms3896 KiB
18Wrong answer0/3298ms4044 KiB
19Wrong answer0/3328ms4008 KiB
20Wrong answer0/3463ms4252 KiB