Submission #970885

#TimeUsernameProblemLanguageResultExecution timeMemory
970885mannshah1211Street Lamps (APIO19_street_lamps)C++17
20 / 100
99 ms9860 KiB
/** * author: hashman * created: **/ #include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include "algo/debug.h" #else #define debug(...) 42 #endif int main() { ios::sync_with_stdio(false); cin.tie(0); int n, q; cin >> n >> q; string s; cin >> s; vector<int> num(n); for (int i = 0; i < n; i++) { num[i] += s[i] - '0'; } for (int i = 0; i < q; i++) { string op; cin >> op; if (op == "query") { int a, b; cin >> a >> b; int ans = num[--a]; if (s[a] == '1') { ans += i; } cout << ans << '\n'; } else { int lamp; cin >> lamp; lamp--; s[lamp] = '1' + '0' - s[lamp]; if (s[lamp] == '1') { num[lamp] -= i; } else { num[lamp] += i; } } } } // Cute is justice!
#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...