This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define f first
#define s second
#define all(x) x.begin(),x.end()
#define _ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
void setIO(string s) {
freopen((s + ".in").c_str(), "r", stdin);
freopen((s + ".out").c_str(), "w", stdout);
}
struct qry{
int t,a,b;
};
const int mxn=2e6+5;
int x[mxn],y[mxn];
int prv[mxn];
vector<int> xs;
vector<int> segtree(mxn*4,-1);
void update(int pos,int val,int l=0,int r=xs.size()-1,int v=1){
if(l==r){
segtree[v]=max(segtree[v],val);
return;
}
int mid=(l+r)/2;
if(pos<=mid) update(pos,val,l,mid,v*2);
else update(pos,val,mid+1,r,v*2+1);
segtree[v]=max(segtree[v*2],segtree[v*2+1]);
}
int search(int tl,int tr,int val,int l=0,int r=xs.size()-1,int v=1){
if(r<tl or tr<l){
return -1;
}
if(segtree[v]<val){
return -1;
}
if(l==r) return l;
int mid=(l+r)/2;
int res=search(tl,min(mid,tr),val,l,mid,v*2);
if(res!=-1) return res;
return search(max(mid+1,tl),tr,val,mid+1,r,v*2+1);
}
int main() {_
int n,m,q;
cin>>n>>m>>q;
for(int i=1;i<=m;i++){
cin>>x[i]>>y[i];
}
vector<qry> qs(q);
for(int i=0;i<q;i++){
cin>>qs[i].t>>qs[i].a;
if(qs[i].t==4) cin>>qs[i].b;
if(qs[i].t==2) xs.push_back(qs[i].a);
}
sort(all(xs));
xs.resize(unique(all(xs))-xs.begin());
int cur=m;
for(int i=0;i<q;i++){
int t=qs[i].t;
int a=qs[i].a;
int b=qs[i].b;
if(t==1){
int pos=lower_bound(all(xs),y[a])-xs.begin();
int res=search(pos,xs.size()-1,prv[a]);
if(res!=-1){
x[a]=max(x[a],n-xs[res]);
}
//cout<<res<<'\n';
cout<<x[a]<<' '<<y[a]<<'\n';
prv[a]=i;
}
else if(t==2){
int pos=lower_bound(all(xs),a)-xs.begin();
update(pos,i);
}
else{
prv[++m]=i;
x[m]=a;
y[m]=b;
}
}
return 0;
}
//maybe its multiset not set
//yeeorz
//laborz
Compilation message (stderr)
sweeping.cpp: In function 'int main()':
sweeping.cpp:68:9: warning: unused variable 'cur' [-Wunused-variable]
68 | int cur=m;
| ^~~
sweeping.cpp: In function 'void setIO(std::string)':
sweeping.cpp:15:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
15 | freopen((s + ".in").c_str(), "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sweeping.cpp:16:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
16 | freopen((s + ".out").c_str(), "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# | 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... |