Cod sursa(job #2269553)

Utilizator BogauuuBogdan Ivancu Bogauuu Data 26 octombrie 2018 10:20:34
Problema Pachete Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.91 kb
#include <fstream>
#include <algorithm>

using namespace std;

ifstream fin("pachete.in");
ofstream fout("pachete.out");

struct pachet
{
    int l,c;
};

 pachet p[50002];
 int xs,ys,n;

 bool cmp(pachet x, pachet y)
 {
     /*int dxl=x.l-xs;
     int dxc=x.c-ys;
     int dyl=y.l-xs;
     int dyc=y.c-ys;
     if (dxl<0) dxl*=(-1);
     if (dxc<0) dxc*=(-1);
     if (dyl<0) dyl*=(-1);
     if (dyc<0) dyc*=(-1);
     int dx=dxl+dxc;
     int dy=dyl+dyc;
     if (dx<=dy) return 1;
     else return 0;*/
     if (x.l<y.l) return 1;
     else
     {
         if (x.l==y.l && x.c<=y.c) return 1;
         else return 0;
     }
 }

 int i;

int main()
{
    fin >> n >> xs >> ys;
    for (i=1;i<=n;i++)
    {
        fin >> p[i].l >> p[i].c;
    }
    sort (p+1,p+n+1,cmp);
    for (i=1;i<=n;i++)
    {
        fout << p[i].l << " " << p[i].c << "\n";
    }

    return 0;
}