#include <fstream>
using namespace std;
ifstream fin("date.in");
ofstream fout("date.out");
struct punct
{
int x,y;
};
int x[100], p[100], n,s;
punct a[100], b[100];
void citire(punct a[], punct b[], int &n)
{
fin>>n;
for(int i=1;i<=n;i++) fin>>a[i].x>>a[i].y;
for(int i=1;i<=n;i++) fin>>b[i].x>>b[i].y;
}
void afis(int n)
{
for(int i=1;i<=n;i++)
fout<<"("<<a[i].x<<","<<a[i].y<<")-("<<b[x[i]].x<<","<<b[x[i]].y<<")"<<endl;
fout<<endl;
}
int dreapta(punct a, punct b, punct c)//pozitia lui c fata de dreapta a-b
{
return (c.x-a.x)*(b.y-a.y)-(c.y-a.y)*(b.x-a.x);
}
int bun(int k)
{
for(int i=1;i<k;i++)
if(dreapta(a[i],b[x[i]],a[k])*dreapta(a[i],b[x[i]],b[x[k]])<0 &&
dreapta(a[k],b[x[k]],a[i])*dreapta(a[k],b[x[k]],b[x[i]])<0) return 0;
return 1;
}
void back(int x[],int k)
{
int i;
for(i=1;i<=n;i++)
if(!p[i])
{
x[k]=i;
p[i]=1;
if(bun(k)) if(k==n) afis(k);
else back(x,k+1);
p[i]=0;
}
}
int main()
{
citire(a,b,n);
back(x,1);
fin.close();
fout.close();
return 0;
}
|