#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
#define pii pair<int, int>
#define pi3 pair<pii, int>
#define ft first
#define sd second
#define MP3(a,b,c) MP(MP(a,b),c)
using namespace std;
typedef long long ll;
const int N = 50100;
const int M = 100100;
const int Q = 100100;
const int CO = 200100;
const int oo = 2e9;
//const int B = 1300;
const int B = 1;
const int MB = M / B + 10;
string s, qr;
int n, q, tp[N], lst[N], sum[N];
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 < n; i++){
sum[i] = 0;
tp[i] = s[i] - '0';
lst[i] = 0;
}
for (int i = 1; i <= q; i++){
cin >> qr;
if (qr[0] == 't'){
int x; cin >> x;
x--;
if (tp[x] == 1)
sum[x] += i - lst[x];
tp[x] ^= 1;
lst[x] = i;
} else {
int a, b; cin >> a >> b;
a--; b--;
int ans = sum[a];
if (tp[a] == 1)
ans += i - lst[a];
cout << ans << '\n';
}
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
77 ms |
3832 KB |
Output is correct |
2 |
Correct |
84 ms |
4856 KB |
Output is correct |
3 |
Correct |
84 ms |
5368 KB |
Output is correct |
4 |
Runtime error |
7 ms |
2964 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 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 |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |