Submission #1044640

#TimeUsernameProblemLanguageResultExecution timeMemory
1044640vjudge1Street Lamps (APIO19_street_lamps)C++17
20 / 100
5052 ms4188 KiB
#include <bits/stdc++.h> #define pb push_back #define endl ("\n") #define all(aa) aa.begin(), aa.end() typedef long long ll; using namespace std; int main(){ int n, q; cin >> n >> q; vector<int> v(n); string s; cin >> s; for(int i = 0; i < n; i++) v[i] = (s[i] == '1'); vector<vector<int>> ans(n, vector<int>(n)); for(int i = 0; i < q; i++){ for(int j = 0; j < n; j++){ for(int k = j; k < n; k++){ int ok = 1; for(int a = j; a <= k; a++) ok &= v[a]; ans[j][k] += ok; } } string t; cin >> t; if(t == "toggle"){ int a; cin >> a; a--; v[a] ^= 1; } else{ int l, r; cin >> l >> r; l--, r-= 2; cout << ans[l][r] << endl; } } }
#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...