28882023-02-01 19:37:53UnluckYSzínezéscpp11Wrong answer 17/50462ms5980 KiB
/*

00001


0101

101010
01010


01010

*/

#include <bits/stdc++.h>

using namespace std;

int main(){

    ios_base::sync_with_stdio(0); cin.tie(0);

    int n, q; cin >> n >> q;
    vector<bool> v;
    vector<int> qs;
    string x; cin >> x;
    for (char i : x){
        if (i == '0') v.push_back(false);
        if (i == '1') v.push_back(true);
    }

    for (int i = 0; i < q; i++){
        int x; cin >> x;
        qs.push_back(x-1);
    }

    vector<bool> v2;
    bool e = !v[0];

    for (bool i : v){
        if (i != e) v2.push_back(i);
        e = i;
    }

    int m = v2.size()/2;
    
    cout << m << endl;

    for (int i : qs){
        v[i] = !v[i];
        if (i == 0){
            if (v[1] != v[i] && v[i] != v[n-1]) m++;
        }
        else if (i == n-1){
            if (v[n-2] != v[i] && v[i] != v[0]) m++;
        }
        else if (v[i-1] != v[i] && v[i+1] != v[i]){
            m++;
        }
        else if (v[i-1] == v[i] && v[i+1] == v[i]){
            m--;
        }
        cout << m << endl;
    }

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base17/50
1Accepted0/03ms1828 KiB
2Accepted0/04ms2176 KiB
3Accepted2/22ms2100 KiB
4Wrong answer0/23ms2332 KiB
5Accepted3/32ms2312 KiB
6Accepted3/33ms2444 KiB
7Wrong answer0/34ms2664 KiB
8Wrong answer0/34ms2752 KiB
9Wrong answer0/24ms2756 KiB
10Wrong answer0/24ms2752 KiB
11Accepted3/3462ms5460 KiB
12Wrong answer0/3312ms5672 KiB
13Wrong answer0/3310ms5760 KiB
14Accepted3/3284ms5756 KiB
15Accepted3/3317ms5860 KiB
16Wrong answer0/3317ms5856 KiB
17Wrong answer0/3300ms5856 KiB
18Wrong answer0/3291ms5852 KiB
19Wrong answer0/3301ms5856 KiB
20Wrong answer0/3435ms5980 KiB