#include <bits/stdc++.h>
#define debug(x) cerr << #x << " " << x << "\n"
#define debugs(x) cerr << #x << " " << x << " "
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx2")
using namespace std;
typedef long long ll;
typedef pair <ll, ll> pii;
const ll NMAX = 300001;
const int INF = 1e9;
const ll nrbits = 20;
const ll MOD = 998244353;
int a[NMAX];
string s[NMAX];
int qa[NMAX];
int qb[NMAX];
int sol[NMAX];
signed main() {
#ifdef HOME
ifstream cin(".in");
ofstream cout(".out");
#endif // HOME
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n, i, q;
cin >> n >> q;
for(i = 1; i <= n; i++){
char c;
cin >> c;
a[i] = c - '0';
}
for(i = 1; i <= q; i++){
cin >> s[i];
cin >> qa[i];
if(s[i][0] == 'q'){
cin >> qb[i];
qb[i]--;
}
}
for(i = 1; i <= q; i++){
for(int j = i; j <= q; j++){
int ok = 1;
for(int t = qa[j]; t <= qb[j]; t++){
ok &= (a[t] == 1);
}
if(ok){
sol[j]++;
}
}
if(s[i][0] == 't'){
a[qa[i]] ^= 1;
}
if(s[i][0] == 'q')
cout << sol[i] << "\n";
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
13148 KB |
Output is correct |
2 |
Correct |
2 ms |
13148 KB |
Output is correct |
3 |
Correct |
3 ms |
13148 KB |
Output is correct |
4 |
Correct |
4 ms |
13148 KB |
Output is correct |
5 |
Correct |
4 ms |
13400 KB |
Output is correct |
6 |
Correct |
3 ms |
13148 KB |
Output is correct |
7 |
Correct |
3 ms |
13148 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
5049 ms |
13456 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
13148 KB |
Output is correct |
2 |
Correct |
8 ms |
12984 KB |
Output is correct |
3 |
Correct |
13 ms |
13148 KB |
Output is correct |
4 |
Correct |
20 ms |
13144 KB |
Output is correct |
5 |
Execution timed out |
5062 ms |
19028 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
20 ms |
13144 KB |
Output is correct |
2 |
Correct |
17 ms |
13148 KB |
Output is correct |
3 |
Correct |
13 ms |
13224 KB |
Output is correct |
4 |
Correct |
4 ms |
13148 KB |
Output is correct |
5 |
Execution timed out |
5067 ms |
20236 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
13148 KB |
Output is correct |
2 |
Correct |
2 ms |
13148 KB |
Output is correct |
3 |
Correct |
3 ms |
13148 KB |
Output is correct |
4 |
Correct |
4 ms |
13148 KB |
Output is correct |
5 |
Correct |
4 ms |
13400 KB |
Output is correct |
6 |
Correct |
3 ms |
13148 KB |
Output is correct |
7 |
Correct |
3 ms |
13148 KB |
Output is correct |
8 |
Execution timed out |
5049 ms |
13456 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |