Submission #265101

#TimeUsernameProblemLanguageResultExecution timeMemory
265101hanagasumiStreet Lamps (APIO19_street_lamps)C++17
20 / 100
5077 ms524292 KiB
#include <iostream> #include <vector> #include <cmath> #include <algorithm> #include <deque> #include <map> #include <set> #include <complex> #include <string> #include <unordered_map> #include <unordered_set> #include <random> #define ft first #define sc second #define pb push_back #define len(v) (int)v.size() #define int ll #define all(v) v.begin(), v.end() using namespace std; typedef long long ll; typedef long double ld; signed main() { #ifdef PC freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout); #endif ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, q; cin >> n >> q; vector<vector<int>> was(q + 1, vector<int> (n, 0)); for (int i = 0; i < n; i++) { char c; cin >> c; was[0][i] = (c - '0'); } for (int i = 0; i < q; i++) { was[i + 1] = was[i]; string s; cin >> s; if(s == "toggle") { int id; cin >> id; id--; was[i + 1][id] = !was[i + 1][id]; continue; } int l, r, ans = 0; cin >> l >> r; l--, r--; for (int j = 0; j <= i; j++) { int fl = 1; for (int z = l; z < r; z++) { if(!was[j][z]) fl = 0; } ans += fl; } 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...