Submission #1004999

#TimeUsernameProblemLanguageResultExecution timeMemory
1004999vjudge1Street Lamps (APIO19_street_lamps)C++17
20 / 100
494 ms5104 KiB
#include <bits/stdc++.h> using namespace std; int main() { int n,q; cin>>n>>q; string s; cin>>s; int las[n],su[n]={}; for (int i=0;i<n;i++) if (s[i]=='1') las[i]=0; for (int m=1;m<=q;m++) { string t; cin>>t; if (t=="toggle") { int i; cin>>i; i--; if (s[i]=='0') { las[i]=m; s[i]='1'; } else { su[i]+=m-las[i]; s[i]='0'; } } else { int a,b; cin>>a>>b; a--; int ans=su[a]; if (s[a]=='1') ans+=m-las[a]; cout<<ans<<endl; } } 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...