Submission #1044639

# Submission time Handle Problem Language Result Execution time Memory
1044639 2024-08-05T11:57:50 Z Kel_Mahmut Street Lamps (APIO19_street_lamps) C++14
20 / 100
5000 ms 4372 KB
#include <bits/stdc++.h>
#define pb push_back
#define endl ("\n")
#define all(aa) aa.begin(), aa.end()
typedef long long ll;
using namespace std;

int main(){
	int n, q;
	cin >> n >> q;
	vector<int> v(n);
	string s;
	cin >> s;
	for(int i = 0; i < n; i++) v[i] = (s[i] == '1');

	vector<vector<int>> ans(n, vector<int>(n));
	for(int i = 0; i < q; i++){
		for(int j = 0; j < n; j++){
			for(int k = j; k < n; k++){
				int ok = 1;
				for(int a = j; a <= k; a++)
					ok &= v[a];
				ans[j][k] += ok;
			}
		}
		string t;
		cin >> t;
		if(t == "toggle"){
			int a; cin >> a; a--;
			v[a] ^= 1;
		}
		else{
			int l, r; cin >> l >> r; l--, r-= 2;
			cout << ans[l][r] << endl;
		}
	}

}

# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 6 ms 348 KB Output is correct
5 Correct 6 ms 348 KB Output is correct
6 Correct 7 ms 348 KB Output is correct
7 Correct 7 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 5039 ms 672 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5029 ms 4184 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5025 ms 4372 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 6 ms 348 KB Output is correct
5 Correct 6 ms 348 KB Output is correct
6 Correct 7 ms 348 KB Output is correct
7 Correct 7 ms 348 KB Output is correct
8 Execution timed out 5039 ms 672 KB Time limit exceeded
9 Halted 0 ms 0 KB -