Submission #414653

#TimeUsernameProblemLanguageResultExecution timeMemory
414653fadi57Deda (COCI17_deda)C++14
60 / 140
11 ms388 KiB
#include<bits/stdc++.h> using namespace std; const int mx=1e3; typedef long long ll; int inf=1e9+10; const int mod=1e9+7; int n,m,k,p,l,q; int seg[4*mx]; void build(int node,int st,int en){ if(st==en){ seg[node]=inf; return; } int mid=(st+en)/2; build(node*2,st,mid); build(node*2+1,mid+1,en); seg[node]=inf; return; } void update(int node,int st,int en,int idx,int value){ if(st==en){ seg[node]=value; return; } int mid=(st+en)/2; if(idx<=mid){ update(node*2,st,mid,idx,value); }else{ update(node*2+1,mid+1,en,idx,value); } seg[node]=min(seg[node*2],seg[node*2+1]); return ; } int query(int node,int st,int en,int l,int x){ if(st==en){ if(seg[node]<=x){return st;}else{return -1;} } int mid=(st+en)/2; if(l<=mid&&seg[node*2]<=x){ int z=query(node*2,st,mid,l,x); if(z!=-1){return z;} } if(l<=en&&seg[node*2+1]<=x){ int z=query(node*2+1,mid+1,en,l,x); if(z!=-1){return z;} } return -1; } int main(){ cin>>n>>q; build(1,0,n-1); // cout<<seg[1]<<endl; for(int i=0;i<q;i++){ char c;cin>>c; if(c=='M'){ int x,a;cin>>x>>a; a--; update(1,0,n-1,a,x); // cout<<seg[1]<<endl; } else{ int y,b;cin>>y>>b; b--; int ans=query(1,0,n-1,b,y); if(ans!=-1){ans++;} cout<<ans<<endl; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...