79492024-01-12 08:25:22BenedekMartonSzínezéscpp17Wrong answer 33/50488ms4436 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/03ms1872 KiB
2Accepted0/04ms2072 KiB
3Accepted2/23ms2304 KiB
4Accepted2/23ms2516 KiB
5Accepted3/33ms2728 KiB
6Accepted3/33ms2944 KiB
7Accepted3/34ms3156 KiB
8Accepted3/34ms3368 KiB
9Accepted2/24ms3448 KiB
10Wrong answer0/24ms3544 KiB
11Wrong answer0/3486ms3992 KiB
12Wrong answer0/3363ms4228 KiB
13Accepted3/3291ms4436 KiB
14Accepted3/3405ms4400 KiB
15Wrong answer0/3287ms4392 KiB
16Wrong answer0/3300ms4272 KiB
17Wrong answer0/3488ms4264 KiB
18Accepted3/3460ms4264 KiB
19Accepted3/3479ms4268 KiB
20Accepted3/3296ms4268 KiB