Submission #675829

#TimeUsernameProblemLanguageResultExecution timeMemory
675829Dan4LifeStreet Lamps (APIO19_street_lamps)C++17
20 / 100
7 ms2356 KiB
#include <bits/stdc++.h>
using namespace std;

const int maxn = (int)3e5+10;

string s;
int a[maxn], st[101][maxn];
int n, q;

int32_t main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n >> q >> s;
	for(int i = 1; i <= n; i++) a[i] = (s[i-1]=='1'), st[0][i]=a[i];

	for(int i = 1; i <= q; i++){
		int x, y; cin >> s >> x;
		if(s[0]=='t'){
			a[x]^=1;
		}
		else{
			cin >> y; int ans = 0;
			for(int j = 0; j < i; j++){
				bool ok = true;
				for(int k = x; k < y; k++) ok&=(st[j][k]==1);
				ans+=ok;
			}
			cout << ans << "\n";
		}
		for(int j = 1; j <= n; j++) st[i][j] = a[j];
	}
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...