#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);
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
860 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
870 ms |
97296 KB |
Output is correct |
2 |
Correct |
837 ms |
97300 KB |
Output is correct |
3 |
Correct |
880 ms |
97164 KB |
Output is correct |
4 |
Correct |
715 ms |
96096 KB |
Output is correct |
5 |
Correct |
700 ms |
97472 KB |
Output is correct |
6 |
Correct |
737 ms |
97044 KB |
Output is correct |
7 |
Correct |
820 ms |
98508 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
750 ms |
99008 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
750 ms |
99008 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
860 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |