Advertisement
MAGCARI

Mafia Node

Aug 9th, 2022 (edited)
686
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.94 KB | None | 0 0
  1. /*
  2.     Task    : Mafia Node
  3.     Author  : Phumipat C. [MAGCARI]
  4.     Language: C++
  5.     Created : 09 August 2022 [18:48]
  6. */
  7. #include<bits/stdc++.h>
  8. using namespace std;
  9. struct A{
  10.     int w,id;
  11.     bool operator < (const A&o) const{
  12.         if(w != o.w)    return w<o.w;
  13.         else            return id<o.id;
  14.     }
  15. };
  16. priority_queue<A > heap;
  17. int sc[1000010],del[1000010];
  18. int main(){
  19.     int n,l,r,x,y;
  20.     char opr;
  21.     scanf("%d %d %d",&n,&l,&r);
  22.     for(int i=1;i<=n;i++)
  23.         heap.push({0,i});
  24.     l+=r;
  25.     while(l--){
  26.         scanf(" %c",&opr);
  27.         if(opr == 'L'){
  28.             scanf("%d %d",&x,&y);
  29.             sc[y]++;
  30.             heap.push({sc[y],y});
  31.         }else if(opr == 'C'){
  32.             scanf("%d %d",&x,&y);
  33.             sc[y]+=3;
  34.             heap.push({sc[y],y});
  35.         }else if(opr == 'R'){
  36.             while(!heap.empty() && del[heap.top().id])  heap.pop();
  37.             printf("%d\n",heap.top().id);
  38.         }else if(opr == 'D'){
  39.             while(!heap.empty() && del[heap.top().id])  heap.pop();
  40.             del[heap.top().id] = 1;
  41.             //unnecessary
  42.             heap.pop();
  43.         }
  44.     }
  45.     return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement