#include<iostream>
#include<queue>
#include<string>
#include<cstdio>
using namespace std;
class complex
{
public:
int real;
int image;
complex(int a=0,int b=0)
{
real=a;
image=b;
}
};
class cmp
{
public:
bool operator()(complex a,complex b)
{
return a.real*a.real+a.image*a.image<b.real*b.real+b.image*b.image;
}
};
int main()
{
string command;
int t,n,a,b;
cin>>t;
while(t--)
{
priority_queue<complex,vector<complex>,cmp>qe;
cin>>n;
while(n--)
{
cin>>command;
if(command=="Insert"){
scanf("%d+i%d",&a,&b);
complex temp(a,b);
qe.push(temp);
cout<<"Size: "<<qe.size()<<endl;
}
else{
if(qe.empty())cout<<"Empty!\n";
else{
cout<<qe.top().real<<"+i"<<qe.top().image<<endl;
qe.pop();
if(qe.empty())cout<<"Empty!\n";
else cout<<"Size: "<<qe.size()<<endl;
}
}
}
}
}
BUPT OJ 虚数
最新推荐文章于 2019-03-25 22:47:14 发布