Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Task : Mafia Node
- Author : Phumipat C. [MAGCARI]
- Language: C++
- Created : 09 August 2022 [18:48]
- */
- #include<bits/stdc++.h>
- using namespace std;
- struct A{
- int w,id;
- bool operator < (const A&o) const{
- if(w != o.w) return w<o.w;
- else return id<o.id;
- }
- };
- priority_queue<A > heap;
- int sc[1000010],del[1000010];
- int main(){
- int n,l,r,x,y;
- char opr;
- scanf("%d %d %d",&n,&l,&r);
- for(int i=1;i<=n;i++)
- heap.push({0,i});
- l+=r;
- while(l--){
- scanf(" %c",&opr);
- if(opr == 'L'){
- scanf("%d %d",&x,&y);
- sc[y]++;
- heap.push({sc[y],y});
- }else if(opr == 'C'){
- scanf("%d %d",&x,&y);
- sc[y]+=3;
- heap.push({sc[y],y});
- }else if(opr == 'R'){
- while(!heap.empty() && del[heap.top().id]) heap.pop();
- printf("%d\n",heap.top().id);
- }else if(opr == 'D'){
- while(!heap.empty() && del[heap.top().id]) heap.pop();
- del[heap.top().id] = 1;
- //unnecessary
- heap.pop();
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement