Submission #858289

#TimeUsernameProblemLanguageResultExecution timeMemory
85828912345678Street Lamps (APIO19_street_lamps)C++17
20 / 100
76 ms10980 KiB
#include <bits/stdc++.h> using namespace std; const int nx=3e5+5; int n, q, lst[nx], sm[nx], l, a, b; string s; int main() { cin.tie(NULL)->sync_with_stdio(false); cin>>n>>q>>s; for (int i=1; i<=n; i++) lst[i]=(s[i-1]-'0')-1; for (int i=1; i<=q; i++) { cin>>s; if (s[0]=='t') { cin>>l; if (lst[l]==-1) lst[l]=i; else sm[l]+=(i-lst[l]), lst[l]=-1; } else { cin>>a>>b; if (lst[a]!=-1) cout<<sm[a]+(i-lst[a])<<'\n'; else cout<<sm[a]<<'\n'; } } } /* 5 7 11111 query 1 2 query 2 3 query 3 4 query 4 5 query 5 6 toggle 1 query 1 2 */
#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...