Submission #733038

#TimeUsernameProblemLanguageResultExecution timeMemory
733038boyliguanhanStreet Lamps (APIO19_street_lamps)C++17
20 / 100
5023 ms524288 KiB
#include<bits/stdc++.h> using namespace std; char opposite(char c) { if(c=='0') return '1'; return '0'; } bool ok(string str, int a, int b) { for(int i = a-1; i < b-1; i++) { if(str[i]=='0') return 0; } return 1; } int main() { int n, q; cin >> n >> q; vector<string> states; string str; cin >> str; states.push_back(str); for(int i = 0; i < q; i++) { string type; int a, b; cin >> type >> a; if(type=="toggle") { str[a-1] = opposite(str[a-1]); } else { cin >> b; int ans = 0; for(auto i: states) ans+=ok(i, a, b); cout << ans << '\n'; } states.push_back(str); } }
#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...