Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<set>
- #include<string>
- #include<algorithm>
- using namespace std;
- struct point
- {
- int x;
- int y;
- point(int x,int y)
- :x(x),y(y){}
- int dist() const
- {
- return x*x+y*y;
- }
- };
- struct cmp
- {
- bool operator()(const point &x , const point &y)const
- {
- return x.dist() < y.dist();
- }
- };
- ostream& operator<< (ostream &os, const point &pnt) {
- return os<<pnt.x<<' '<<pnt.y<<endl;
- }
- int main()
- {
- multiset<point,cmp> a;
- while(1)
- {
- string command;
- int x,y,r;
- cin>>command;
- if(command=="remove")
- {
- x=a.size();
- cin>>r;
- a.erase(point(0,r));
- cout<<x-a.size()<<" points were removed"<<endl;
- }
- if(command=="print")
- {
- cin>>r;
- for(auto it=a.equal_range(point(0,r)).first;it!=a.equal_range(point(0,r)).second;++it)
- {
- cout<<*it;
- }
- }
- if(command=="add")
- {
- cin>>x>>y;
- a.insert(point(x,y));
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement