Pagini recente » Cod sursa (job #2025934) | Cod sursa (job #667500) | Cod sursa (job #266742) | Cod sursa (job #332525) | Cod sursa (job #253892)
Cod sursa(job #253892)
#include <fstream>
#include <algorithm>
using namespace std;
ifstream fin("grendizer.in");
ofstream fout("grendizer.out");
#define NMAX 100010
struct punct
{
int x,y,s;
};
int modul(int h)
{
if (h>=0) return h; else return -h;
}
int sortare(punct a, punct b)
{
if (a.s>=b.s) return 0;
else return 1;
}
int v[4]={-1,1,1,-1},b[4]={-1,-1,1,1};
int N,M;
punct A[200000];
int main()
{
int i,xi,yi;
fin>>N>>M;
for (i=1;i<=N;i++)
{
fin>>A[2*i-1].x>>A[2*i-1].y;
A[2*i].x=A[2*i-1].x, A[2*i].y=A[2*i-1].y;
A[2*i].s=modul(A[2*i].x+A[2*i].y);
A[2*i-1].s=modul(A[2*i-1].x-A[2*i].y);
}
sort(A+1,A+2*N+1,sortare);
for (i=1;i<=M;i++)
{
fin>>xi>>yi;
}
fout.close();
return 0;
}