38522023-03-03 12:10:24ZsofiaKeresztelySzínezéscpp14Wrong answer 12/50546ms7788 KiB
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n, q, val=0;
    cin >> n >> q;
    vector<int> b(n+1);
    b[0] = -1;
    for (int i=1; i<=n; i++){
        char c;
        cin >> c;
        b[i] = c - '0';
        if (b[i] != b[i-1]) val++;
    }
    val /= 2;
    cout << val << "\n";
    b.push_back(b[b.size()-2]);
    b[0] = b[2];
    while (q--){
        int a;
        cin >> a;
        b[a] = 1 - b[a];
        if (n == 1){
            cout << 0 << "\n";
            continue;
        }
        if (a == 1 || a == n || b[a-1] == b[a+1]) val += (b[a-1] == b[a] || b[a+1] == b[a]) ? -1 : +1;
        cout << val << "\n";
    }
}
SubtaskSumTestVerdictTimeMemory
base12/50
1Wrong answer0/03ms1812 KiB
2Accepted0/06ms2260 KiB
3Wrong answer0/23ms2268 KiB
4Accepted2/23ms2656 KiB
5Accepted3/33ms2732 KiB
6Wrong answer0/33ms2916 KiB
7Accepted3/34ms3096 KiB
8Wrong answer0/34ms3316 KiB
9Accepted2/24ms3520 KiB
10Accepted2/24ms3608 KiB
11Wrong answer0/3307ms6872 KiB
12Wrong answer0/3513ms7092 KiB
13Wrong answer0/3303ms7044 KiB
14Wrong answer0/3430ms7108 KiB
15Wrong answer0/3541ms7416 KiB
16Wrong answer0/3307ms7688 KiB
17Wrong answer0/3504ms7640 KiB
18Wrong answer0/3517ms7788 KiB
19Wrong answer0/3503ms7636 KiB
20Wrong answer0/3546ms7632 KiB