Submission #983734

#TimeUsernameProblemLanguageResultExecution timeMemory
983734pccStreet Lamps (APIO19_street_lamps)C++17
20 / 100
79 ms11968 KiB
#include <bits/stdc++.h> using namespace std; const int mxn = 3e5+10; int arr[mxn],pre[mxn],sum[mxn]; int N,Q; int main(){ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin>>N>>Q; if(N>mxn||Q>mxn)return 0; string s; cin>>s; s = "#"+s; for(int i = 1;i<=N;i++){ arr[i] = s[i]-'0'; pre[i] = 0; } for(int i = 1;i<=Q;i++){ string tp; cin>>tp; if(tp[0] == 'q'){ int a,b; cin>>a>>b; cout<<sum[a]+arr[a]*(i-pre[a])<<'\n'; } else{ int a; cin>>a; sum[a] += arr[a]*(i-pre[a]); pre[a] = i; arr[a] ^= 1; } } 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...