# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1117219 | hoangnoobpro | Deda (COCI17_deda) | C++17 | 526 ms | 9260 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.
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define nmax 200007
#define fi first
#define se second
#define ll long long
ll t=1,n,m=0,i=0,j=0,d=0,x=0,k=0,y=0,z,a[nmax],st[nmax*4],l,r,mid,kq;
char ch;
void update(ll id,ll l,ll r,ll vt,ll gt)
{
if(r<vt||l>vt)return;
if(l==r)
{
st[id]=gt;
return;
}
ll mid=(l+r)/2;
update(id*2,l,mid,vt,gt);
update(id*2+1,mid+1,r,vt,gt);
st[id]=min(st[id*2],st[id*2+1]);
}
void get(ll id,ll l,ll r,ll u,ll v)
{
if(r<u||l>v)return;
if(u<=l&&r<=v)
{
d=min(d,st[id]);
return;
}
ll mid=(l+r)/2;
get(id*2,l,mid,u,v);
get(id*2+1,mid+1,r,u,v);
}
int main()
{
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>n>>t;
for(i=1;i<nmax-2;++i)st[i]=1e17;
while(t--)
{
cin>>ch>>x>>y;
if(ch=='M')
{
update(1,1,n,y,x);
continue;
}
l=y;
r=n;
kq=-1;
while(l<=r)
{
mid=(l+r)/2;
d=1e17;
get(1,1,n,y,mid);
if(d<=x)
{
kq=mid;
r=mid-1;
}
else l=mid+1;
}
cout<<kq<<"\n";
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |