Submission #999906

#TimeUsernameProblemLanguageResultExecution timeMemory
999906UnforgettableplSweeping (JOI20_sweeping)C++17
11 / 100
1777 ms62292 KiB
#include <bits/stdc++.h> using namespace std; #define int long long int treeX[6000001]; int treeY[6000001]; int arrX[1500001]; int arrY[1500001]; int M; void updatelazy(int qL,int qR,int qX,int *tree,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,tree,2*x,L,mid); updatelazy(qL,qR,qX,tree,2*x+1,mid+1,R); } void propagate(int qX,int *arr,int *tree,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,arr,tree,2*x,L,mid); propagate(qX,arr,tree,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); for(int i=1;i<=m;i++)cin>>dusts[i].first>>dusts[i].second; M = m; for(int i=1;i<=m;i++){ updatelazy(i,i,dusts[i].first,treeX); updatelazy(i,i,dusts[i].second,treeY); } for(int i=1;i<=q;i++){ int type;cin>>type; if(type==1){ int x;cin>>x; propagate(x,arrX,treeX); propagate(x,arrY,treeY); cout << arrX[x] << ' ' << arrY[x] << '\n'; } else if(type==2){ int l;cin>>l; int last = m+1; for(int jump=262144;jump;jump/=2){ if(last-jump<=0)continue; propagate(last-jump,arrY,treeY); if(arrY[last-jump]<=l)last-=jump; } if(last<=m)updatelazy(last,m,n-l,treeX); } else { int l;cin>>l; int last = 0; for(int jump=262144;jump;jump/=2){ if(last+jump>m)continue; propagate(last+jump,arrX,treeX); if(arrX[last+jump]<=l)last+=jump; } if(last)updatelazy(1,last,n-l,treeY); } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...