This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define debug(a) cout << #a << " = " << a << endl
#define debugsl(a) cout << #a << " = " << a << ", "
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define repa(i,a,b) for(int i = (a); i >= (b); i--)
#define MAX 300000
struct x{
lli estado;
lli val;
lli ultmod;
};
string st;
lli q,n,a,b,res,dif;
x arr[MAX+2];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n >> q;
cin >> st;
rep(i,0,n-1) {
if (st[i] == '0') arr[i+1] = {0,0,0};
else arr[i+1] = {1,0,0};
}
rep(i,1,q) {
cin >> st >> a;
if (st[0] == 't') {
dif = i - arr[a].ultmod;
arr[a].val += dif*arr[a].estado;
arr[a].estado ^= 1;
arr[a].ultmod = i;
}
else {
cin >> b;
dif = i - arr[a].ultmod;
arr[a].val += dif*arr[a].estado;
arr[a].ultmod = i;
cout << arr[a].val << endl;
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |