Submission #721761

#TimeUsernameProblemLanguageResultExecution timeMemory
721761GrandTiger1729Street Lamps (APIO19_street_lamps)C++17
20 / 100
160 ms5352 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), res(n); for (int qq = 1; qq <= q; qq++){ string ty; cin >> ty; if (ty == "toggle"){ int i; cin >> i; i--; if (a[i]) res[i] += qq - 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...