Submission #545247

#TimeUsernameProblemLanguageResultExecution timeMemory
545247amunduzbaevStreet Lamps (APIO19_street_lamps)C++17
20 / 100
61 ms10236 KiB
#include "bits/stdc++.h" using namespace std; #define ar array namespace sub1{ void solve(int n, int q){ vector<string> s(q + 1); cin>>s[0]; for(int i=1;i<=q;i++){ s[i] = s[i-1]; string t; cin>>t; if(t == "query"){ int l, r; cin>>l>>r; --l, --r; int res = 0; for(int j=0;j<i;j++){ bool ok = 1; for(int k=l;k<r;k++){ if(s[j][k] == '0') ok = 0; } res += ok; } cout<<res<<"\n"; } else { int p; cin>>p; p--; s[i][p] = '1' - s[i][p] + '0'; } } } }; namespace sub2{ void solve(int n, int q, string& s, vector<ar<int, 3>>& qq){ vector<int> sum(n); for(int i=0;i<q;i++){ if(qq[i][0]){ int p = --qq[i][1]; if(s[p] == '0') sum[p] -= i, s[p] = '1'; else sum[p] += i, s[p] = '0'; } else { int p = --qq[i][1]; cout<<sum[p] + (s[i] == '1') * i<<"\n"; } } } }; namespace sub3{ void solve(int n, int q, string& s, vector<ar<int, 3>>& qq){ } }; signed main(){ ios::sync_with_stdio(0); cin.tie(0); int n, q; cin>>n>>q; if(n <= 100 && q <= 100){ sub1::solve(n, q); } else { string s; cin>>s; bool is = 1; vector<ar<int, 3>> qq(q); for(int i=0;i<q;i++){ string t; cin>>t; if(t == "query"){ cin>>qq[i][1]>>qq[i][2]; if(qq[i][2] - qq[i][1] != 1) is = 0; } else { qq[i][0] = 1; cin>>qq[i][1]; } } if(is){ sub2::solve(n, q, s, qq); } else { sub3::solve(n, q, s, qq); } } }
#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...