# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
472886 | MamdouhN | Deda (COCI17_deda) | C++14 | 1095 ms | 2776 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 int long long
#define endl "\n"
int n,q;
int seg[600005];
int uwu = 92716301829;
void update(int idx,int st,int en,int i,int value)
{
if(en<i||st>i)return;
if(st==en)
{
seg[idx] = value;
return;
}
int mid = (st+en)/2;
update(idx*2,st,mid,i,value);
update(idx*2+1,mid+1,en,i,value);
seg[idx]=min(seg[idx*2],seg[idx*2+1]);
}
int query(int idx,int st,int en,int qs,int y)
{
if(en<qs||st>n)return uwu;
if(seg[idx]>y)return uwu;
if(st==en)return (seg[st]==0?uwu:st);
int mid = (st+en)/2;
int left = query(idx*2,st,mid,qs,y);
int right = query(idx*2+1,mid+1,en,qs,y);
return min(left,right);
}
main()
{
cin>>n>>q;
while(q--)
{
char c;
int a,b;
cin>>c>>a>>b;
if(c=='M')
{
update(1,0,n,b,a);
}
else
{
int ans = query(1,0,n,b,a);
cout<<(ans==uwu ? -1:ans)<<endl;
}
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |