230012026-01-16 10:29:48ProgramozoRokaSzínezéscpp17Accepted 50/50432ms2484 KiB
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int n, q;
    cin >> n >> q;
    vector<bool>golyok;
    int szam = 0;
    for (int i = 0; i < n; ++i)
    {
        char k;
        cin >> k;
        golyok.push_back(k - 48);
        if (i == 0 or golyok[i] != golyok[i - 1]) szam++;
    }
    int helyes = szam;
    vector<int>megoldas;
    for (int in = 0; in < q; ++in)
    {
        int i;
        cin >> i;
        --i;
        if (i > 0) {
            if (golyok[i] != golyok[i - 1]) szam--; 
            else szam++;                        
        }
        if (i < n - 1) {
            if (golyok[i] != golyok[i + 1]) szam--;
            else szam++;                         
        }
        golyok[i] =!golyok[i];
        megoldas.push_back(szam/2);
    }
    cout << helyes/2 << endl;
    for (int i = 0; i < megoldas.size(); ++i)
        cout << megoldas[i] << endl;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/01ms316 KiB
2Accepted0/03ms316 KiB
3Accepted2/21ms500 KiB
4Accepted2/21ms316 KiB
5Accepted3/31ms316 KiB
6Accepted3/31ms316 KiB
7Accepted3/33ms316 KiB
8Accepted3/33ms404 KiB
9Accepted2/22ms316 KiB
10Accepted2/23ms316 KiB
11Accepted3/3397ms2328 KiB
12Accepted3/3432ms2332 KiB
13Accepted3/3393ms2328 KiB
14Accepted3/3391ms2360 KiB
15Accepted3/3405ms2472 KiB
16Accepted3/3423ms2368 KiB
17Accepted3/3421ms2316 KiB
18Accepted3/3405ms2360 KiB
19Accepted3/3398ms2484 KiB
20Accepted3/3416ms2468 KiB