#include <bits/stdc++.h>
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define pll pair<ll, ll>
#define MP make_pair
#define PB push_back
using namespace std;
typedef long long ll;
const int N = 300100;
const int M = 300100;
const int oo = 2e9;
string qr, s, t;
int n, q, loc[M], ans;
bool typ[M];
bool check(int l, int r){
for (int i = l; i < r; i++)
if (t[i] == '0')
return 0;
return 1;
}
int main(){
#ifdef _LOCAL
freopen("in.txt","r",stdin);
#else
ios_base::sync_with_stdio(0); cin.tie(0);
#endif // _LOCAL
cin >> n >> q >> s;
for (int i = 0; i < q; i++){
cin >> qr;
if (qr[0] == 't'){
typ[i] = 1;
cin >> loc[i];
loc[i]--;
} else{
int l, r; cin >> l >> r;
l--; r--;
ans = 0;
t = s;
for (int j = 0; j <= i; j++) {
if (typ[j]) {
t[loc[j]] = (t[loc[j]] == '1' ? '0' : '1');
} else ans += check(l, r);
}
cout << ans << '\n';
}
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
5061 ms |
1620 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Incorrect |
6 ms |
384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
6 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |