이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
void PlayGround() {
int n, q;
cin>>n>>q;
vector<int>state(n);
for(int i=0; i<n; ++i) {
char c;
cin>>c;
state[i] = c-'0';
}
vector<int>op;
for(int i=0; i<q; ++i) {
string type;
cin>>type;
if(type=="toggle") {
int j;
cin>>j;
op.push_back(j-1);
} else {
op.push_back(-1);
int a, b;
cin>>a>>b;
--a, --b;
int len = b-a;
int cnt = 0;
for(int j=a; j<b; ++j) {
cnt += state[j];
}
int ans = 0;
vector<int>temp = state;
for(int j=0; j<=i; ++j) {
if(op[j]==-1) ans += len==cnt;
else {
ans += len==cnt;
temp[op[j]] ^= 1;
if(op[j]>=a && op[j]<b) cnt += temp[op[j]]?1:-1;
}
}
cout<<ans<<'\n';
}
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
PlayGround();
return 0;
}
# | 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... |