Submission #983733

#TimeUsernameProblemLanguageResultExecution timeMemory
983733pccStreet Lamps (APIO19_street_lamps)C++17
20 / 100
1 ms476 KiB
#include <bits/stdc++.h> using namespace std; const int mxn = 555; string s; string state[mxn]; int N,Q; bool check(string &s,int a,int b){ for(int i = a;i<b;i++){ if(s[i] == '0')return false; } return true; } int main(){ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin>>N>>Q; if(N>mxn||Q>mxn)return 0; cin>>s; s = "#"+s; state[0] = s; for(int i = 1;i<=Q;i++){ string tp; cin>>tp; state[i] = state[i-1]; if(tp[0] == 'q'){ int a,b; cin>>a>>b; int ans = 0; for(int j = 0;j<i;j++){ if(check(state[j],a,b))ans++; } cout<<ans<<'\n'; } else{ int a; cin>>a; state[i][a] = (state[i][a] == '0'?'1':'0'); } } 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...