#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++) {
if(s[i][0] == 't') {
a[qa[i]] ^= 1;
} else {
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] == 'q')
cout << sol[i] << "\n";
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
13148 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
5026 ms |
16560 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
13144 KB |
Output is correct |
2 |
Incorrect |
5 ms |
13144 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
22 ms |
13144 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
13148 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |