Submission #869506

#TimeUsernameProblemLanguageResultExecution timeMemory
869506tch1cherinStreet Lamps (APIO19_street_lamps)C++17
20 / 100
57 ms3548 KiB
#include <bits/stdc++.h> using namespace std; int main() { cin.tie(nullptr)->sync_with_stdio(false); int N, Q; string S; cin >> N >> Q >> S; if (N <= 100 && Q <= 100) { vector<string> states = {S}; while (Q--) { string T; cin >> T; if (T == "toggle") { int P; cin >> P; P--; S[P] ^= 1; } else { int L, R; cin >> L >> R; L--, R--; int ans = 0; for (auto value : states) { ans += value.substr(L, R - L) == string(R - L, '1'); } cout << ans << "\n"; } states.push_back(S); } } else { vector<int> sum(N), last(N), par(N); for (int i = 0; i < N; i++) { par[i] = S[i] - '0'; } for (int i = 1; i <= Q; i++) { string T; cin >> T; if (T == "toggle") { int P; cin >> P; P--; if (par[P] == 1) { sum[P] += i - last[P]; par[P] ^= 1; last[P] = i; } } else { int L, R; cin >> L >> R; L--, R--; int ans = sum[L]; if (par[L] == 1) { ans += i - last[L]; } cout << ans << "\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...