제출 #1174603

#제출 시각아이디문제언어결과실행 시간메모리
1174603tkm_algorithms가로등 (APIO19_street_lamps)C++20
20 / 100
1935 ms1444 KiB
/**
*    In the name of Allah
*    We are nothing and you're everything
*    author: najmuddin
**/
#include <bits/stdc++.h>
using namespace std;
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
#define int ll
const char nl = '\n';
const int N = 101;

int g[N][N];
int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int n, q; cin >> n >> q;
	
	string s; cin >> s;
	s = '&'+s;
	
	while (q--) {
		string tp; cin >> tp;
		for (int i = 1; i <= n; ++i) {
			for (int j = i+1; j <= n+1; ++j) {
				bool ok = true;
				for (int k = i; k < j; ++k) {
					if (s[k] == '0')ok = false;
					if (!ok)break;
				}
				if (ok)g[i][j] += 1;
			}
		}
		if (tp == "query") {
			int u, v; cin >> u >> v;
			cout << g[u][v] << nl;
		} else {
			int i; cin >> i;
			if (s[i] == '1')s[i] = '0';
			else s[i] = '1';
		}
		
	}
	return 0;
}
#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...