Submission #1044942

#TimeUsernameProblemLanguageResultExecution timeMemory
1044942vjudge1Street Lamps (APIO19_street_lamps)C++17
20 / 100
58 ms7392 KiB
#include <bits/stdc++.h> #define fast cin.tie(0)->sync_with_stdio(0); #define int long long #define inf ((int)1e18) using namespace std; int32_t main(){ fast int n, q; cin >> n >> q; string s; cin >> s; vector <int> till(n, -1), ans(n); // till[ind] = 0 means closed for(int i = 0; i < n; i++) { if(s[i] == '1') till[i] = 0; } for(int i = 1; i <= q; i++) { string type; cin >> type; if(type == "toggle") { int ind; cin >> ind; ind--; if(~till[ind]) { ans[ind] += i - till[ind]; till[ind] = -1; } else { till[ind] = i; } } else { int a, b; cin >> a >> b; a--, b-=2; int tmp = (~till[a]) ? i - till[a] : 0; cout << tmp + ans[a] << "\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...