Submission #972963

#TimeUsernameProblemLanguageResultExecution timeMemory
972963UnforgettableplStreet Lamps (APIO19_street_lamps)C++17
20 / 100
86 ms11196 KiB
#include <bits/stdc++.h> using namespace std; #define int long long bool state[300001]; int ans[300001]; int last[300001]; int32_t main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); int n,q; cin >> n >> q; for(int i=1;i<=n;i++){ char a;cin>>a; if(a=='1')state[i]=true; } for(int i=1;i<=q;i++){ string type;cin>>type; if(type=="toggle"){ int x;cin>>x; if(!state[x]){ state[x]=true; last[x] = i; } else { state[x]=false; ans[x]+=i-last[x]; } } else { int l,r;cin>>l>>r; int offset = 0; if(state[l])offset+=i-last[l]; cout << ans[l]+offset << '\n'; } } }
#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...