Submission #281975

#TimeUsernameProblemLanguageResultExecution timeMemory
281975Revo7Deda (COCI17_deda)C++14
60 / 140
1082 ms6520 KiB
#include <bits/stdc++.h> #define ll long long #define pb push_back #define left 2*i+1 #define righ 2*i+2 #define mid (l+r)/2 #define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); using namespace std; const ll maxn=2e5+100; const ll mod=1e9+9; const ll base=27; const ll inf =1e9+10; ll n,q; int st[4*maxn]; struct player{ ll val,cnt,id; }; vector<player>a; bool com(player a,player b){ if(a.val==b.val){ if(a.cnt==b.cnt)return a.id>b.id; return a.cnt<b.cnt; } return a.val<b.val; } ll pl[6][maxn]; struct sub{ ll tim,x,y; }; bool cmp(sub a,sub b){ return a.tim<b.tim; } vector<sub>s; bool flag[maxn],sw[6][maxn]; int in[maxn]; void build(int i,int l,int r){ if(l==r){ st[i]=inf; return; } build(left,l,mid); build(righ,mid+1,r); st[i]=inf; } void upd(int i,int l,int r,int id,int val){ if(r<id||l>id)return ; if(l==r){ st[i]=val; return ; } upd(left,l,mid,id,val); upd(righ,mid+1,r,id,val); st[i]=min(st[left],st[righ]); } int qur(int i,int l,int r,int ql,int qr){ if(r<ql||l>qr)return inf; if(l>=ql&&r<=qr)return st[i]; return min(qur(left,l,mid,ql,qr),qur(righ,mid+1,r,ql,qr)); } bool check(int l,int r,int val){ return qur(0,0,n-1,l,r)<=val; } int bs(int b,int val){ int l=b,r=n-1,ans=-2; while(l<=r){ if(check(b,mid,val)){ ans=mid; r=mid-1; } else l=mid+1; } return ans; } int main() { //setIO("threesum"); IOS cin>>n>>q; build(0,0,n-1); while(q--){ char t; cin>>t; if(t=='M'){ int x,a; cin>>x>>a; upd(0,0,n-1,a-1,x); } else{ int y,b; cin>>y>>b; cout<<bs(b-1,y)+1<<endl; } } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...