Skip to content

Commit

Permalink
1178
Browse files Browse the repository at this point in the history
  • Loading branch information
githubgood committed Apr 15, 2014
1 parent e1b2045 commit 5aff1f3
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions 1178
@@ -0,0 +1,57 @@
#include <algorithm>
#include <vector>
#include <iostream>
#include <cstdio>
using namespace std;
struct info
{
int a;
int b;
};
bool cmp(const info &x,const info &y)
{
if(x.a*x.a+x.b*x.b==y.a*y.a+y.b*y.b)
return x.b>y.b;
else
return x.a*x.a+x.b*x.b<y.a*y.a+y.b*y.b;
};
int main()
{
string s;
char a[50];
vector<info>v;
info in;
int m,p,q;
while(cin>>m)
{
getchar();
while(m--)
{
gets(a);
s=a;
if(s=="Pop")
{
if(v.size()==0)
{
cout<<"empty"<<endl;
}
else
{
cout<<v[v.size()-1].a<<"+i"<<v[v.size()-1].b<<endl;
v.pop_back();
cout<<"SIZE = "<<v.size()<<endl;
}
}
else
{
sscanf(a,"Insert %d+i%d",&p,&q);
in.a=p;
in.b=q;
v.push_back(in);
sort(v.begin(),v.end(),cmp);
cout<<"SIZE = "<<v.size()<<endl;
}
}
v.clear();
}
}

0 comments on commit 5aff1f3

Please sign in to comment.