This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 << (get(l,r)==INT32_MAX ? i : get(l,r)) << '\n';
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |