Submission #869994

#TimeUsernameProblemLanguageResultExecution timeMemory
869994AloraStreet Lamps (APIO19_street_lamps)C++17
0 / 100
59 ms688 KiB
#include <bits/stdc++.h> #define Alora "cownav" #define fi(i,a,b) for(int i = a; i <= b; i++) #define fid(i,a,b) for(int i = a; i >= b; i--) #define ll long long #define f first #define se second #define pii pair<int, int> #define getbit(i, j) ((i >> j) & 1) #define all(v) v.begin(), v.end() #define pb push_back #define maxn 300005 const int M = 1e9 + 7; using namespace std; int n, m, st[maxn*4]; string s; void build(int id, int l, int r){ if(l == r){ if(s[l] == '1') st[id] = 1e9; else st[id] = 0; return; } int m = (l + r)/2; build(id*2, l, m); build(id*2 + 1, m + 1, r); st[id] = min(st[id*2], st[id*2 + 1]); } void ud(int id, int l, int r, int u, int x){ if(l > x || r < x) return; if(l == r) {st[id] = min(st[id], x); return;} int m = (l + r)/2; ud(id*2, l, m, u, x); ud(id*2 + 1, m + 1, r, u, x); st[id] = min(st[id*2], st[id*2 + 1]); } int get(int id, int l, int r, int u, int v){ if(l > v || r < u) return 1e9; if(u <= l && r <= v) return st[id]; int m = (l + r)/2; return min(get(id*2, l, m, u, v), get(id*2 + 1, m + 1, r, u, v)); } int main(){ ios_base::sync_with_stdio(0); cin.tie(NULL); cin >> n >> m; cin >> s; s = ' ' + s; build(1, 1, n); fi(i, 1, m){ string c; cin >> c; if(c == "toggle"){ int x; cin >> x; ud(1, 1, n, x, i - 1); } else{ int a, b; cin >> a >> b; int x = get(1, 1, n, a, b - 1); cout << min(x, i) << '\n'; } } return 0; }
#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...