# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
942346 | vjudge1 | Deda (COCI17_deda) | C++17 | 79 ms | 5776 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define OYY 100000000000005
#define mod 1000000007
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define FOR for(int i=1;i<=n;i++)
#define mid (start+end)/2
#define lim 200005
#define fi first
#define se second
int tree[4*lim];
int ans;
bool stop;
inline void build(int node,int start,int end){
if(start>end)return ;
if(start==end){
tree[node]=OYY;
return ;
}
build(node*2,start,mid),build(node*2+1,mid+1,end);
tree[node]=tree[node*2];
}
inline void update(int node,int start,int end,int l,int r,int val){
if(start>end || start>r || end<l)return ;
if(start>=l && end<=r){
tree[node]=val;
return;
}
update(node*2,start,mid,l,r,val),update(node*2+1,mid+1,end,l,r,val);
tree[node]=min(tree[node*2],tree[node*2+1]);
}
inline void query(int node,int start,int end ,int l,int r,int maxi){
if(start>end || start>r || end<l)return ;
if(tree[node]>maxi)return ;
if(stop)return ;
if(start==end){
ans=start;
stop=true;
return;
}
query(node*2,start,mid,l,r,maxi),query(node*2+1,mid+1,end,l,r,maxi);
}
int32_t main(){
faster
int n,q;cin>>n>>q;
build(1,1,n);
while(q--){
char c;int x,y;cin>>c>>x>>y;
if(c=='M'){
update(1,1,n,y,y,x);
}
else{
ans=-1;stop=false;
query(1,1,n,y,n,x);
cout<<ans<<'\n';
}
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |