Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef complex<double> P;
 
namespace std{
  bool operator < ( const P &a, const P &b ){
    return (a.real()==b.real()?a.imag()<b.imag():a.real()<b.real());
  }
};
 
struct S{
  P p,q;
  S(P p=P(0,0),P q=P(0,0)):p(p),q(q){}  
};
 
 
double eps=1e-8;
 
bool eq(double a,double b){
  return -eps < a-b && a-b < eps;
}

bool eq(P a,P b){
  return abs(a-b)<eps;
}
 
double dot(P a,P b){ return real(b*conj(a)); }
 
double cross(P a,P b){ return imag(b*conj(a)); }
 
P reflect(P a,P b,P c){
  b-=a;c-=a;
  return a+conj(c/b)*b;
}
 
S reflect(S base,S s){
  P a=reflect( base.p, base.q , s.p );
  P b=reflect( base.p, base.q , s.q );
  return S(a,b);
}
 
int ccw(P a,P b,P c){
  b-=a;
  c-=a;
  P k=c*conj(b);
  if(k.imag()>eps)return 1;
  if(k.imag()<-eps)return -1;
  if(k.real()<-eps)return 2;
  if(abs(c)>abs(b)+eps)return -2;
  return 0;
}
 
int ccw(S s,P p){
  return ccw( s.p , s.q , p);
}
 
bool isIntersect(S s1,S s2){
  P a=s1.p;
  P b=s1.q;
  P c=s2.p;
  P d=s2.q;
  return (ccw(a,b,c)*ccw(a,b,d)<=0&&
          ccw(c,d,a)*ccw(c,d,b)<=0);
}
 
bool isIntersectLS(S line,S segment){
  return (ccw(line,segment.p)*ccw(line,segment.q)<=0);
}
 
P getCrossPointLL(S l1,S l2){
  P a=l1.p , b=l1.q;
  P c=l2.p , d=l2.q;
  a-=d;b-=d;c-=d;
  return d+a+(b-a)*imag(a/c)/imag(a/c-b/c);
}

bool isParallel( S a, S b){
  return eq(0, cross(a.p-a.q, b.p-b.q) );
}

int N;
P si;
P t[10];
int id[8];

typedef pair<double,int> Pair;

bool check(){
  vector<S> tri;
  vector<S> v;
  vector<P> events;
  
  for(int i=0;i<N;i++){
    int j=(i+1)%N;
    v.push_back( S(t[i],t[j]) );
  }
  
  for(int i=0;i<N;i++){

    for(int j=0;j<N;j++)if(i>0)events.push_back(v[j].p);
    
    int index=id[i];
    tri.push_back( v[index] );
    for(int j=0;j<N;j++)v[j]=reflect(tri.back(),v[j]);
  }
   

  events.push_back( tri.back().p );
  events.push_back( tri.back().q );


  
  for(int I=0;I<(int)events.size();I++){
    P p=events[I];
    S line=S(si,p);
    if( eq(p,si) )assert(0);
 
    vector<Pair> pre;
    bool flg=true;
    bool left=false;
    bool right=false;
    
    for(int k=0;k<(int)tri.size();k++){
      S s=tri[k];

      assert( isParallel(line,s)==false );
      
      if( !isIntersectLS(line,s) ){
        flg=false;
        break;
      }
      
      P target=getCrossPointLL(line,s);
      P tmp;
      if( eq(target, s.p ) ){
        tmp=s.q;
        if( ccw( target, tmp ) == 1 ) left=true;
        if( ccw( target, tmp ) == -1 ) right=true;
      }else if( eq(target,s.q ) ){
        tmp=s.p;
        if( ccw( target, tmp ) == 1 ) left=true;
        if( ccw( target, tmp ) == -1 ) right=true;
      }


      
      if( dot(p-si,target-si) < -eps ){
        flg=false;
        break;
      }
      pre.push_back( Pair(abs(target-si),k) );
    }//k
 

    sort(pre.begin(),pre.end());
    for(int i=0;i<(int)pre.size();i++)
      if(pre[i].second!=i)flg=false;

    if(flg&& (!left||!right) )return true;
  }
   
  return false;
}
 
P input(){
  int x,y;
  scanf("%d %d",&x,&y);
  return P(x,y);
}
 
int main(){
  while(1){
    scanf("%d",&N);
    if(N==0)break;
    si=input();
    for(int i=0;i<N;i++){
      t[i]=input();
    }
    int ans=0;
    for(int i=0;i<N;i++)id[i]=i;
    do{
      if(check())ans++;
    }while( next_permutation(id,id+N) );
    printf("%d\n",ans);
  }
  return 0;
}
#include<bits/stdc++.h>
using namespace std;
typedef complex<double> P;
 
namespace std{
  bool operator < ( const P &a, const P &b ){
    return (a.real()==b.real()?a.imag()<b.imag():a.real()<b.real());
  }
};
 
struct S{
  P p,q;
  S(P p=P(0,0),P q=P(0,0)):p(p),q(q){}  
};
 
 
double eps=1e-8;
 
bool eq(double a,double b){
  return -eps < a-b && a-b < eps;
}

bool eq(P a,P b){
  return abs(a-b)<eps;
}
 
double dot(P a,P b){ return real(b*conj(a)); }
 
double cross(P a,P b){ return imag(b*conj(a)); }
 
P reflect(P a,P b,P c){
  b-=a;c-=a;
  return a+conj(c/b)*b;
}
 
S reflect(S base,S s){
  P a=reflect( base.p, base.q , s.p );
  P b=reflect( base.p, base.q , s.q );
  return S(a,b);
}
 
int ccw(P a,P b,P c){
  b-=a;
  c-=a;
  P k=c*conj(b);
  if(k.imag()>eps)return 1;
  if(k.imag()<-eps)return -1;
  if(k.real()<-eps)return 2;
  if(abs(c)>abs(b)+eps)return -2;
  return 0;
}
 
int ccw(S s,P p){
  return ccw( s.p , s.q , p);
}
 
bool isIntersect(S s1,S s2){
  P a=s1.p;
  P b=s1.q;
  P c=s2.p;
  P d=s2.q;
  return (ccw(a,b,c)*ccw(a,b,d)<=0&&
          ccw(c,d,a)*ccw(c,d,b)<=0);
}
 
bool isIntersectLS(S line,S segment){
  return (ccw(line,segment.p)*ccw(line,segment.q)<=0);
}
 
P getCrossPointLL(S l1,S l2){
  P a=l1.p , b=l1.q;
  P c=l2.p , d=l2.q;
  a-=d;b-=d;c-=d;
  return d+a+(b-a)*imag(a/c)/imag(a/c-b/c);
}

bool isParallel( S a, S b){
  return eq(0, cross(a.p-a.q, b.p-b.q) );
}

int N;
P si;
P t[10];
int id[8];

typedef pair<double,int> Pair;

bool check(){
  vector<S> tri;
  vector<S> v;
  vector<P> events;
  
  for(int i=0;i<N;i++){
    int j=(i+1)%N;
    v.push_back( S(t[i],t[j]) );
  }
  
  for(int i=0;i<N;i++){

    for(int j=0;j<N;j++)if(i>0)events.push_back(v[j].p);
    
    int index=id[i];
    tri.push_back( v[index] );
    for(int j=0;j<N;j++)v[j]=reflect(tri.back(),v[j]);
  }
   

  events.push_back( tri.back().p );
  events.push_back( tri.back().q );


  
  for(int I=0;I<(int)events.size();I++){
    P p=events[I];
    S line=S(si,p);
    if( eq(p,si) )assert(0);
 
    vector<Pair> pre;
    bool flg=true;
    bool left=false;
    bool right=false;
    
    for(int k=0;k<(int)tri.size();k++){
      S s=tri[k];

      assert( isParallel(line,s)==false );
      
      if( !isIntersectLS(line,s) ){
        flg=false;
        break;
      }
      
      P target=getCrossPointLL(line,s);
      P tmp;
      if( eq(target, s.p ) ){
        tmp=s.q;
        if( ccw( target, tmp ) == 1 ) left=true;
        if( ccw( target, tmp ) == -1 ) right=true;
      }else if( eq(target,s.q ) ){
        tmp=s.p;
        if( ccw( target, tmp ) == 1 ) left=true;
        if( ccw( target, tmp ) == -1 ) right=true;
      }


      
      if( dot(p-si,target-si) < -eps ){
        flg=false;
        break;
      }
      pre.push_back( Pair(abs(target-si),k) );
    }//k
 

    sort(pre.begin(),pre.end());
    for(int i=0;i<(int)pre.size();i++)
      if(pre[i].second!=i)flg=false;

    if(flg&& (!left||!right) )return true;
  }
   
  return false;
}
 
P input(){
  int x,y;
  scanf("%d %d",&x,&y);
  return P(x,y);
}
 
int main(){
  while(1){
    scanf("%d",&N);
    if(N==0)break;
    si=input();
    for(int i=0;i<N;i++){
      t[i]=input();
    }
    int ans=0;
    for(int i=0;i<N;i++)id[i]=i;
    do{
      if(check())ans++;
    }while( next_permutation(id,id+N) );
    printf("%d\n",ans);
  }
  return 0;
}

Compiler output:
a.cc:193:8: error: redefinition of 'bool std::operator<(const P&, const P&)'
  193 |   bool operator < ( const P &a, const P &b ){
      |        ^~~~~~~~
a.cc:6:8: note: 'bool std::operator<(const P&, const P&)' previously defined here
    6 |   bool operator < ( const P &a, const P &b ){
      |        ^~~~~~~~
a.cc:198:8: error: redefinition of 'struct S'
  198 | struct S{
      |        ^
a.cc:11:8: note: previous definition of 'struct S'
   11 | struct S{
      |        ^
a.cc:204:8: error: redefinition of 'double eps'
  204 | double eps=1e-8;
      |        ^~~
a.cc:17:8: note: 'double eps' previously defined here
   17 | double eps=1e-8;
      |        ^~~
a.cc:206:6: error: redefinition of 'bool eq(double, double)'
  206 | bool eq(double a,double b){
      |      ^~
a.cc:19:6: note: 'bool eq(double, double)' previously defined here
   19 | bool eq(double a,double b){
      |      ^~
a.cc:210:6: error: redefinition of 'bool eq(P, P)'
  210 | bool eq(P a,P b){
      |      ^~
a.cc:23:6: note: 'bool eq(P, P)' previously defined here
   23 | bool eq(P a,P b){
      |      ^~
a.cc:214:8: error: redefinition of 'double dot(P, P)'
  214 | double dot(P a,P b){ return real(b*conj(a)); }
      |        ^~~
a.cc:27:8: note: 'double dot(P, P)' previously defined here
   27 | double dot(P a,P b){ return real(b*conj(a)); }
      |        ^~~
a.cc:216:8: error: redefinition of 'double cross(P, P)'
  216 | double cross(P a,P b){ return imag(b*conj(a)); }
      |        ^~~~~
a.cc:29:8: note: 'double cross(P, P)' previously defined here
   29 | double cross(P a,P b){ return imag(b*conj(a)); }
      |        ^~~~~
a.cc:218:3: error: redefinition of 'P reflect(P, P, P)'
  218 | P reflect(P a,P b,P c){
      |   ^~~~~~~
a.cc:31:3: note: 'P reflect(P, P, P)' previously defined here
   31 | P reflect(P a,P b,P c){
      |   ^~~~~~~
a.cc:223:3: error: redefinition of 'S reflect(S, S)'
  223 | S reflect(S base,S s){
      |   ^~~~~~~
a.cc:36:3: note: 'S reflect(S, S)' previously defined here
   36 | S reflect(S base,S s){
      |   ^~~~~~~
a.cc:229:5: error: redefinition of 'int ccw(P, P, P)'
  229 | int ccw(P a,P b,P c){
      |     ^~~
a.cc:42:5: note: 'int ccw(P, P, P)' previously defined here
   42 | int ccw(P a,P b,P c){
      |     ^~~
a.cc:240:5: error: redefinition of 'int ccw(S, P)'
  240 | int ccw(S s,P p){
      |     ^~~
a.cc:53:5: note: 'int ccw(S, P)' previously defined here
   53 | int ccw(S s,P p){
      |     ^~~
a.cc:244:6: error: redefinition of 'bool isIntersect(S, S)'
  244 | bool isIntersect(S s1,S s2){
      |      ^~~~~~~~~~~
a.cc:57:6: note: 'bool isIntersect(S, S)' previously defined here
   57 | bool isIntersect(S s1,S s2){
      |      ^~~~~~~~~~~
a.cc:253:6: error: redefinition of 'bool isIntersectLS(S, S)'
  253 | bool isIntersectLS(S line,S segment){
      |      ^~~~~~~~~~~~~
a.cc:66:6: note: 'bool isIntersectLS(S, S)' previously defined here
   66 | bool isIntersectLS(S line,S segment){
      |      ^~~~~~~~~~~~~
a.cc:257:3: error: redefinition of 'P getCrossPointLL(S, S)'
  257 | P getCrossPointLL(S l1,S l2){
      |   ^~~~~~~~~~~~~~~
a.cc:70:3: note: 'P getCrossPointLL(S, S)' previously defined here
   70 | P getCrossPointLL(S l1,S l2){
      |   ^~~~~~~~~~~~~~~
a.cc:264:6: error: redefinition of 'bool isParallel(S, S)'
  264 | bool isParallel( S a, S b){
      |      ^~~~~~~~~~
a.cc:77:6: note: 'bool isParallel(S, S)' previously defined here
   77 | bool isParallel( S a, S b){
      |      ^~~~~~~~~~
a.cc:268:5: error: redefinition of 'int N'
  268 | int N;
      |     ^
a.cc:81:5: note: 'int N' previously declared here
   81 | int N;
      |     ^
a.cc:269:3: error: redefinition of 'P si'
  269 | P si;
      |   ^~
a.cc:82:3: note: 'P si' previously defined here
   82 | P si;
      |   ^~
a.cc:270:3: error: redefinition of 'P t [10]'
  270 | P t[10];
      |   ^
a.cc:83:3: note: 'P t [10]' previously defined here
   83 | P t[10];
      |   ^
a.cc:271:5: error: redefinition of 'int id [8]'
  271 | int id[8];
      |     ^~
a.cc:84:5: note: 'int id [8]' previously declared here
   84 | int id[8];
      |     ^~
a.cc:275:6: error: redefinition of 'bool check()'
  275 | bool check(){
      |      ^~~~~
a.cc:88:6: note: 'bool check()' previously defined here
   88 | bool check(){
      |      ^~~~~
a.cc:352:3: error: redefinition of 'P input()'
  352 | P input(){
      |   ^~~~~
a.cc:165:3: note: 'P input()' previously defined here
  165 | P input(){
      |   ^~~~~
a.cc:358:5: error: redefinition of 'int main()'
  358 | int main(){
      |     ^~~~
a.cc:171:5: note: 'int main()' previously defined here
  171 | int main(){
      |     ^~~~