Submission #973113

#TimeUsernameProblemLanguageResultExecution timeMemory
973113UnforgettableplStreet Lamps (APIO19_street_lamps)C++17
0 / 100
63 ms11564 KiB
#include <bits/stdc++.h> using namespace std; #define int long long int tree[1048576]; int last[300001]; int get(int l,int r){ int ans = INT32_MAX; l+=524288;r+=524288; while(l<=r){ if(l&1)ans=min(ans,tree[l++]); if(r%2==0)ans = min(ans,tree[r--]); l/=2;r/=2; } return ans; } void update(int k,int x){ k+=524288; tree[k] = x; k/=2; while(k){ tree[k] = min(tree[2*k],tree[2*k+1]); k/=2; } } int32_t main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); for(int&i:tree)i=INT32_MAX; int n,q; cin >> n >> q; for(int i=1;i<=n;i++){ char a;cin>>a; if(a=='0')update(i,0); } for(int i=1;i<=q;i++){ string type;cin>>type; if(type=="toggle"){ int x;cin>>x; update(x,i); } else { int l,r;cin>>l>>r;r--; cout << min(get(l,r),i) << '\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...