38392023-03-03 11:16:35ZsofiaKeresztelySzínezéscpp14Wrong answer 14/50522ms7388 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.size()-2);
    b[0] = b[2];
    while (q--){
        int a;
        cin >> a;
        b[a] = 1 - b[a];
        if (b[a-1] == b[a+1]) val += b[a-1] == b[a] ? -1 : +1;
        cout << val << "\n";
    }
}
SubtaskSumTestVerdictTimeMemory
base14/50
1Accepted0/03ms1816 KiB
2Accepted0/06ms2260 KiB
3Wrong answer0/23ms2344 KiB
4Wrong answer0/23ms2372 KiB
5Wrong answer0/32ms2444 KiB
6Accepted3/32ms2412 KiB
7Accepted3/34ms2556 KiB
8Wrong answer0/34ms2768 KiB
9Accepted2/24ms2848 KiB
10Wrong answer0/24ms2976 KiB
11Wrong answer0/3333ms6220 KiB
12Wrong answer0/3492ms6176 KiB
13Wrong answer0/3522ms6180 KiB
14Accepted3/3463ms6496 KiB
15Accepted3/3509ms6836 KiB
16Wrong answer0/3416ms6724 KiB
17Wrong answer0/3430ms7040 KiB
18Wrong answer0/3303ms7308 KiB
19Wrong answer0/3449ms7136 KiB
20Wrong answer0/3492ms7388 KiB