79922024-01-12 09:45:55BenedekMartonSzínezéscpp17Wrong answer 33/50510ms4628 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-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/2 << endl;
        g[v]=!g[v];
    }
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base33/50
1Accepted0/03ms1744 KiB
2Accepted0/06ms1920 KiB
3Accepted2/23ms2120 KiB
4Accepted2/23ms2372 KiB
5Accepted3/33ms2456 KiB
6Accepted3/33ms2420 KiB
7Accepted3/34ms2548 KiB
8Accepted3/34ms2792 KiB
9Accepted2/24ms3136 KiB
10Wrong answer0/24ms3212 KiB
11Wrong answer0/3510ms3912 KiB
12Wrong answer0/3358ms3980 KiB
13Accepted3/3508ms3956 KiB
14Accepted3/3430ms3980 KiB
15Wrong answer0/3460ms4232 KiB
16Wrong answer0/3291ms4312 KiB
17Wrong answer0/3296ms4524 KiB
18Accepted3/3509ms4572 KiB
19Accepted3/3374ms4628 KiB
20Accepted3/3509ms4584 KiB