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
int tree[6000001];
int arr[1500001];
int M;
void updatelazy(int qL,int qR,int qX,int x=1,int L=1,int R=M){
if(qR<L or R<qL)return;
if(qL<=L and R<=qR){
tree[x] = max(tree[x],qX);
return;
}
int mid = (L+R)/2;
updatelazy(qL,qR,qX,2*x,L,mid);
updatelazy(qL,qR,qX,2*x+1,mid+1,R);
}
void updateset(int qIdx,int qX,int x=1,int L=1,int R=M){
if(tree[x]){
if(L==R)arr[L]=max(arr[L],tree[x]);
else {
tree[2*x] = max(tree[2*x],tree[x]);
tree[2*x+1] = max(tree[2*x+1],tree[x]);
}
tree[x]=0;
}
if(qIdx<L or R<qIdx)return;
if(L==R){
arr[L] = qX;
return;
}
int mid = (L+R)/2;
updateset(qIdx,qX,2*x,L,mid);
updateset(qIdx,qX,2*x+1,mid+1,R);
}
void propagate(int qX,int x=1,int L=1,int R=M){
if(qX<L or R<qX)return;
if(tree[x]){
if(L==R)arr[L]=max(arr[L],tree[x]);
else {
tree[2*x] = max(tree[2*x],tree[x]);
tree[2*x+1] = max(tree[2*x+1],tree[x]);
}
tree[x]=0;
}
if(L==R)return;
int mid = (L+R)/2;
propagate(qX,2*x,L,mid);
propagate(qX,2*x+1,mid+1,R);
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n,m,q;
cin >> n >> m >> q;
vector<pair<int,int>> dusts(m+1);
vector<pair<int,int>> queries;
for(int i=1;i<=m;i++)cin>>dusts[i].first>>dusts[i].second;
for(int i=1;i<=q;i++){
int type;cin>>type;
if(type==1){
int x;cin>>x;
queries.emplace_back(1,x);
} else if(type==2){
int l;cin>>l;
queries.emplace_back(2,l);
} else {
int x,y;cin>>x>>y;
dusts.emplace_back(x,y);
m++;
queries.emplace_back(4,m);
}
}
M = m;
vector<pair<int,int>> sorted_dust(m+1);
for(int i=1;i<=m;i++)sorted_dust[i]={dusts[i].second,i};
sort(sorted_dust.begin(),sorted_dust.end());
vector<int> lookup(m+1);
for(int i=1;i<=m;i++)lookup[sorted_dust[i].second]=i;
for(int i=1;i<=m;i++){
updateset(lookup[i],dusts[i].first);
}
for(auto[type,x]:queries){
if(type==1){
propagate(lookup[x]);
cout << arr[lookup[x]] << ' ' << dusts[x].second << '\n';
} else if(type==2){
auto maxi = upper_bound(sorted_dust.begin(),sorted_dust.end(),make_pair(x,(int)1e9))-sorted_dust.begin()-1;
if(maxi==0)continue;
updatelazy(1,maxi,n-x);
} else {
updateset(lookup[x],dusts[x].first);
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |