#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define S second
#define F first
#define all(x) (x).begin(),(x).end()
#define sz size()
#define Yes cout << "YES" << endl
#define No cout << "NO" << endl
#define pb(x) push_back(x);
#define endl '\n'
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int N=3e5+7;
ll INF=INT_MAX,mod=1e9+7;
int TT=1;
ll power(ll x, unsigned int y)
{
ll res = 1;
x = x; // % mod;
if (x == 0) return 0;
while (y > 0)
{
if (y & 1) res = (res*x) ; // % mod;
y = y>>1;
x = (x*x) ; // % mod;
}
return res;
}
pair<ll,ll> ans[N];
void solve()
{
ll n , q; cin >> n >> q;
string s; cin >> s;
for(int i = 0; i < n; i++) if(s[i]=='1') ans[i].S = 0;
for(int i =1 ; i <= q; i++)
{
string t; cin >> t;
if(t[0]=='q')
{
ll a, b; cin >> a >> b;
a--,b--;
if(s[a]=='0') cout << ans[a].F << endl;
else cout << ans[a].F + i-ans[a].S << endl;
}
else
{
ll a; cin >> a; a--;
if(s[a]=='0') s[a] = '1', ans[a].S = i;
else s[a] = '0', ans[a].F +=i-ans[a].S;
}
}
}
int main(){
//freopen("friday.in","r",stdin);
//freopen("friday.out","w",stdout);
fast;
while(TT--)
solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
51 ms |
4328 KB |
Output is correct |
2 |
Correct |
56 ms |
4692 KB |
Output is correct |
3 |
Correct |
54 ms |
5456 KB |
Output is correct |
4 |
Correct |
64 ms |
11240 KB |
Output is correct |
5 |
Correct |
64 ms |
11876 KB |
Output is correct |
6 |
Correct |
68 ms |
10952 KB |
Output is correct |
7 |
Correct |
74 ms |
7292 KB |
Output is correct |
8 |
Correct |
74 ms |
13288 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |