Submission #721744

#TimeUsernameProblemLanguageResultExecution timeMemory
721744GrandTiger1729Street Lamps (APIO19_street_lamps)C++17
0 / 100
66 ms1740 KiB
#include <bits/stdc++.h> using namespace std; int main(){ cin.tie(0)->sync_with_stdio(0); int n, q; cin >> n >> q; vector<bool> a(n); for (int i = 0; i < n; i++){ char c; cin >> c; a[i] = c - '0'; } vector<int> lst(n, -1), res(n); for (int qq = 0; qq < q; qq++){ string ty; cin >> ty; if (ty == "toggle"){ int i; cin >> i; i--; if (a[i]) res[i] += i - lst[i]; a[i] = !a[i]; lst[i] = qq; }else{ int l, r; cin >> l >> r; l--, r--; int ans = res[l]; if (a[l]) ans += qq - lst[l]; cout << ans << '\n'; } } 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...