1572021-02-03 20:11:13kovacs.peter.18fSzínezéscpp11Time limit exceeded 20/50694ms5044 KiB
#include <iostream>
#include <vector>
#include <string>

using namespace std;

string s;

int needed_modify() {
	int length = 1;
	char before = s[0];
	for (int i = 1; i < s.size(); i++) {
		if (s[i] != before) {
			before = s[i];
			++length;
		}
	}
	return length / 2;
}

int main() {
	cin.sync_with_stdio(false);
	cin.tie(nullptr);

	int N, Q;
	cin >> N >> Q;
	cin >> s;
	cout << needed_modify() << '\n';
	for (int i = 0; i < Q; i++) {
		int n;
		cin >> n;
		if (s[n - 1] == '0') {
			s[n - 1] = '1';
		}
		else {
			s[n - 1] = '0';
		}
		cout << needed_modify() << '\n';
	}
}
SubtaskSumTestVerdictTimeMemory
base20/50
1Accepted0/02ms1820 KiB
2Accepted0/09ms2012 KiB
3Accepted2/21ms1936 KiB
4Accepted2/21ms1940 KiB
5Accepted3/31ms1944 KiB
6Accepted3/31ms1948 KiB
7Accepted3/33ms1960 KiB
8Accepted3/33ms1980 KiB
9Accepted2/23ms1984 KiB
10Accepted2/23ms1996 KiB
11Time limit exceeded0/3690ms1784 KiB
12Time limit exceeded0/3629ms2092 KiB
13Time limit exceeded0/3690ms2452 KiB
14Time limit exceeded0/3674ms2952 KiB
15Time limit exceeded0/3634ms3200 KiB
16Time limit exceeded0/3671ms3636 KiB
17Time limit exceeded0/3629ms3920 KiB
18Time limit exceeded0/3685ms4364 KiB
19Time limit exceeded0/3693ms4740 KiB
20Time limit exceeded0/3694ms5044 KiB