Submission #698985

#TimeUsernameProblemLanguageResultExecution timeMemory
698985Abrar_Al_SamitStreet Lamps (APIO19_street_lamps)C++17
20 / 100
5089 ms9704 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...