Submission #902440

#TimeUsernameProblemLanguageResultExecution timeMemory
902440Trisanu_DasStreet Lamps (APIO19_street_lamps)C++17
20 / 100
83 ms12016 KiB
#include <bits/stdc++.h> using namespace std; const int maxn = (int)3e5+10; string s; int n, q, a[maxn], cnt[maxn], t[maxn]; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(0); cin >> n >> q >> s; for(int i = 1; i <= n; i++){ a[i] = (s[i-1] == '1'); t[i] = (a[i] == 1 ? 0 : -1); } for(int i = 1; i <= q; i++){ int x, y; cin >> s >> x; if(s[0]=='t'){ a[x] ^= 1; if(a[x]) t[x] = i; else cnt[x] += i - t[x]; } else cin >> y, cout << cnt[x] + a[x] * (i - t[x]) << "\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...