(UPD: 2024-12-04 14:48 UTC) Judge is not working due to Cloudflare incident. (URL) We can do nothing about it, sorry. After the incident is resolved, we will grade all submissions.

Submission #941633

#TimeUsernameProblemLanguageResultExecution timeMemory
941633blacktulipDeda (COCI17_deda)C++17
0 / 140
32 ms65536 KiB
#include <bits/stdc++.h> using namespace std; typedef long long lo; #define fi first #define se second #define endl "\n" #define int long long #define pb push_back #define fio() 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 ort ((bas+son)/2) #define _ << " " << const lo inf = 1000000000000000000; const lo li = 500005; const lo mod = 1000000007; int n,m,a[li],k,flag,t,x[li],y[li]; int cev; char c[li]; string s; vector<int> v,vec; set<int> st[li*4]; inline void update(int node,int start,int end,int l,int r,int x){ if(start>end || start>r || end<l)return ; st[node].insert(x); if(start>=l && end<=r){return ;}; update(node*2,start,mid,l,r,x),update(node*2+1,mid+1,end,l,r,x); } inline void query(int node,int start,int end,int l,int r,int x){ if(start>end || start>r || end<l)return ; if(start>=l && end<=r){ auto it=st[node].lower_bound(x); if(it!=st[node].end())cev=min(cev,*it); return ; } query(node*2,start,mid,l,r,x),query(node*2+1,mid+1,end,l,r,x); } int32_t main(void){ fio(); cin>>n>>t; for(int i=1;i<=t;i++){ cin>>c[i]>>x[i]>>y[i]; vec.pb(x[i]); } sort(vec.begin(),vec.end()); for(int i=1;i<=t;i++){ x[i]=lower_bound(vec.begin(),vec.end(),x[i])-vec.begin()+1; //~ cout<<i _ x[i]<<endl; if(c[i]=='M'){ update(1,1,n,x[i],x[i],y[i]); } else{ cev=inf; query(1,1,n,1,x[i],y[i]); if(cev==inf)cev=-1; cout<<cev<<endl; } } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...