//#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;
const int inf=1e9+5;
int x[mxn],y[mxn];
int prv[mxn];
set<pair<int,int>> X,Y;
vector<vector<int>> segtree(2,vector<int>(mxn*4,-1));
vector<vector<int>> lazy(2,vector<int>(mxn*4,-1));
map<int,int> usedX,usedY;
int n,m,q;
void push(int id,int v){
if(lazy[id][v]==-1) return;
segtree[id][v*2]=max(segtree[id][v*2],lazy[id][v]);
segtree[id][v*2+1]=max(segtree[id][v*2+1],lazy[id][v]);
lazy[id][v*2]=max(lazy[id][v*2],lazy[id][v]);
lazy[id][v*2+1]=max(lazy[id][v*2+1],lazy[id][v]);
lazy[id][v]=-1;
}
void update(int id,int tl,int tr,int val,int l=1,int r=m,int v=1){
if(r<tl or tr<l){
return;
}
if(tl<=l and r<=tr){
segtree[id][v]=max(segtree[id][v],val);
lazy[id][v]=max(lazy[id][v],val);
return;
}
push(id,v);
int mid=(l+r)/2;
update(id,tl,min(mid,tr),val,l,mid,v*2);
update(id,max(mid+1,tl),tr,val,mid+1,r,v*2+1);
segtree[id][v]=max(segtree[id][v*2],segtree[id][v*2+1]);
}
int query(int id,int pos,int l=1,int r=m,int v=1){
if(l==r){
return segtree[id][v];
}
push(id,v);
int mid=(l+r)/2;
if(pos<=mid) return query(id,pos,l,mid,v*2);
else return query(id,pos,mid+1,r,v*2+1);
}
int main() {_
cin>>n>>m>>q;
for(int i=1;i<=m;i++){
cin>>x[i]>>y[i];
update(0,i,i,x[i]);
update(1,i,i,y[i]);
}
//cout<<'\n';
for(int i=0;i<q;i++){
int t,v;
cin>>t>>v;
if(t==1){
cout<<query(0,v)<<' '<<query(1,v)<<'\n';
}
else if(t==2){
if(usedY.find(v)!=usedY.end()) continue;
int ind=lower_bound(y+1,y+m+1,v,greater<int>())-y;
auto it=Y.lower_bound({n-v,-inf});
if(it!=Y.begin() and !Y.empty()){
it=prev(it);
ind=max(ind,(*it).s+1);
}
if(ind<=m) update(0,ind,m,n-v);
X.insert({v,ind});
usedY[v]++;
}
else{
if(usedX.find(v)!=usedX.end()) continue;
int ind=upper_bound(x+1,x+m+1,v)-x-1;
auto it=X.lower_bound({n-v,-inf});
if(it!=X.begin() and !X.empty()){
it=prev(it);
ind=min(ind,(*it).s-1);
}
if(1<=inf) update(1,1,ind,n-v);
Y.insert({v,ind});
usedX[v]++;
}
}
return 0;
}
//maybe its multiset not set
//yeeorz
//laborz
Compilation message
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);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
74 ms |
156988 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1259 ms |
176496 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2540 ms |
197604 KB |
Output is correct |
2 |
Correct |
2358 ms |
206592 KB |
Output is correct |
3 |
Correct |
1094 ms |
205948 KB |
Output is correct |
4 |
Correct |
1179 ms |
206724 KB |
Output is correct |
5 |
Correct |
2345 ms |
206136 KB |
Output is correct |
6 |
Correct |
2521 ms |
207452 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2540 ms |
197604 KB |
Output is correct |
2 |
Correct |
2358 ms |
206592 KB |
Output is correct |
3 |
Correct |
1094 ms |
205948 KB |
Output is correct |
4 |
Correct |
1179 ms |
206724 KB |
Output is correct |
5 |
Correct |
2345 ms |
206136 KB |
Output is correct |
6 |
Correct |
2521 ms |
207452 KB |
Output is correct |
7 |
Incorrect |
2361 ms |
207220 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
74 ms |
156988 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |