Submission #1005018

#TimeUsernameProblemLanguageResultExecution timeMemory
1005018vjudge1Street Lamps (APIO19_street_lamps)C++17
20 / 100
5069 ms524288 KiB
#include <bits/stdc++.h> using namespace std; int main() { int n,q; cin>>n>>q; string s; cin>>s; int pre[n+1],ans[n][n+1]={}; pre[0]=0; for (int i=0;i<n;i++) pre[i+1]=pre[i]+(s[i]-'0'); for (int i=0;i<n;i++) for (int j=i+1;j<=n;j++) ans[i][j]=(pre[j]-pre[i]==j-i); while (q--) { string t; cin>>t; if (t=="query") { int a,b; cin>>a>>b; cout<<ans[a-1][b-1]<<endl; } else { int i; cin>>i; s[i-1]=char('0'+1-(s[i-1]-'0')); } pre[0]=0; for (int i=0;i<n;i++) pre[i+1]=pre[i]+(s[i]-'0'); for (int i=0;i<n;i++) for (int j=i+1;j<=n;j++) ans[i][j]+=(pre[j]-pre[i]==j-i); } 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...