0

```
My program is to solve the simple problem in the Link[http://codeforces.com/problemset/problem/143/A]
#include <stdio.h>
#include <cstring>
#include <math.h>
#include<set>
#include<iostream>
#include<algorithm>
#define MAXN 25
#define INF 100000000
using namespace std;
struct _point
{
int L;int r;
bool operator<(const _point &a)const{
return (this->L<a.L);
}
};
set<_point> up,down;
int r1,r2,c1,c2,d1,d2;
void solve(){
_point tmp;
for(int i=0;i<(r1+1)/2;i++){
cin>>tmp.L;cin>>tmp.r; up.insert(tmp);
}
for(int i=0;i<(r2+1)/2;i++){
cin>>tmp.L>>tmp.r;down.insert(tmp);
}
set<_point>::iterator it_up=up.begin();
set<_point>::iterator it_down=down.begin();
for(it_up=up.begin();it_up!=up.end();it_up++){
//------------Problem is in the next line(it_down++)------------
for(it_down=down.begin();it_down!=down.end();it_down++){
//-------------------------------------------------------------
if((*it_up).L+(*it_down).L!=c1||(*it_up).r+(*it_down).r!=c2||(*it_up).r+(*it_down).L!=d2||(*it_up).L+(*it_down).r!=d1) {
up.erase(*it_up),down.erase(*it_down);
}
}
}
it_up=up.begin(),it_down=down.begin();
if(!up.empty()&&!down.empty()){
cout<<(*it_up).L<<" "<<(*it_down).r<<endl;
cout<<(*it_down).L<<" "<<(*it_down).r<<endl;
}
else cout<<-1<<endl;
}
int main()
{
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
while(cin>>r1>>r2>>c1>>c2>>d1>>d2) solve();
return 0;
}
Thanks for your HELP,sincerely!
```