#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll, ll>
#define f first
#define s second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) (int)((x).size())
#define pb push_back
#ifdef BALBIT
#define bug(...) cerr<<"#"<<__LINE__<<" "<<#__VA_ARGS__<<": ", _do(__VA_ARGS__)
template<typename T> void _do(T && x ){ cerr<<x<<endl; }
template<typename T, typename ...S> void _do(T && x , S&&...y){ cerr<<x<<", "; _do(y...);}
#define IOS()
#else
#define IOS() ios::sync_with_stdio(0),cin.tie(0)
#define endl '\n'
#define bug(...)
#endif // BALBIT
const int maxn = 3e5+5;
//vector<pii> g[maxn];
bool hi[maxn];
int ans[maxn], lt[maxn];
signed main(){
IOS();
int n,q; cin>>n>>q;
for (int i = 0; i<n; ++i) {
char c; cin>>c;
hi[i] = c=='1';
if (hi[i]) {
lt[i] = -1;
}
}
for (int i = 0; i<q; ++i) {
string s; cin>>s;
if (s[0] == 'q') {
int a, foo; cin>>a>>foo;
-- a;
int re = ans[a];
if (hi[a]) {
re += i - lt[a];
}
cout<<re<<endl;
}else{
int x; cin>>x; --x;
if (hi[x]) {
// turning it off
ans[x] += i - lt[x];
}else{
// on
lt[x] = i;
bug(x,lt[x]);
}
hi[x] ^= 1;
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
74 ms |
1400 KB |
Output is correct |
2 |
Correct |
79 ms |
1400 KB |
Output is correct |
3 |
Correct |
80 ms |
5368 KB |
Output is correct |
4 |
Correct |
102 ms |
8824 KB |
Output is correct |
5 |
Correct |
104 ms |
8056 KB |
Output is correct |
6 |
Correct |
98 ms |
8568 KB |
Output is correct |
7 |
Correct |
123 ms |
7068 KB |
Output is correct |
8 |
Correct |
131 ms |
9720 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |