Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Task : Magic Hat
- Author : Phumipat C. [MAGCARI]
- Language: C++
- Created : 09 August 2022 [18:48]
- */
- #include<bits/stdc++.h>
- using namespace std;
- struct A
- {
- int id,type,w,v,d,x;
- bool operator < (const A&o) const{
- return w>o.w;
- }
- };
- struct B{
- int id,w,v,d,x;
- bool operator < (const B&o) const{
- return d>o.d;
- }
- };
- priority_queue<A > normal;
- priority_queue<B > special;
- int mark[200010];
- int main(){
- int n,m,opr,t,w,v,d,x;
- scanf("%d %d",&n,&m);
- for(int i=1;i<=n+m;i++){
- scanf("%d",&opr);
- if(opr == 1){
- scanf("%d",&t);
- if(t == 1){
- scanf("%d %d",&w,&v);
- normal.push({i,1,w,v,-1,-1});
- }else if(t == 2){
- scanf("%d %d %d",&w,&v,&d);
- normal.push({i,2,w,v,d,-1});
- }else{
- scanf("%d %d %d %d",&w,&v,&d,&x);
- normal.push({i,3,w,v,d,x});
- special.push({i,w,v,d,x});
- }
- }else{
- while(!special.empty()){
- B now = special.top();
- if(now.d >= i)
- break;
- if(mark[now.id]){
- special.pop();
- continue;
- }
- if(now.d < i){
- normal.push({now.id,1,now.x,now.v,0,0});
- special.pop();
- continue;
- }
- }
- while(1){
- if(normal.empty()){
- printf("0\n");
- break;
- }
- A now = normal.top();
- normal.pop();
- if((now.type == 2 || now.type == 3) && now.d < i)
- continue;
- if(mark[now.id])
- continue;
- printf("%d\n",now.v);
- mark[now.id] = 1;
- break;
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement