#include <iostream> #include <algorithm> #include <cmath> #include <string> #include <vector> using namespace std; typedef struct Fu{ int r=0; int i=0; int len; }FuN; FuN V[1010]; bool cmp(FuN n1,FuN n2) { if(n1.len!=n2.len)return n1.len<n2.len; return n1.i>n2.i; } int main() { int n,len=0; cin>>n; while(n--) { string s; cin>>s; if(s=="Pop"){ if(len==0)cout<<"empty"<<endl; else{ sort(V,V+len,cmp); int real = V[len-1].r; int imag = V[len-1].i; len--; cout<<real<<"+i"<<imag<<endl; cout<<"SIZE = "<<len<<endl; } } else { int real,imag; scanf("%d+i%d",&real,&imag);//输入复杂的情况下可以使用scanf!!!! FuN *fu = new FuN(); fu->r = real; fu->i =imag; fu->len = real*real +imag*imag; V[len++] = *fu; cout<<"SIZE = "<<len<<endl; } } } // 64 位输出请用 printf("%lld")