Created
July 13, 2014 19:11
-
-
Save satellitex/2a0740394ec64984c5fd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<bits/stdc++.h> | |
using namespace std; | |
typedef complex<double> P; | |
typedef vector<P> LL; | |
#define EPS (1e-10) | |
LL A; | |
int N; | |
void viewLine(LL a){ | |
cout <<"view LINE"<<endl; | |
for(int i=0;i<(int)a.size();i++){ | |
printf("%.8lf %.8lf\n",a[i].real(),a[i].imag()); | |
} | |
} | |
void inputLine(LL &l){ | |
int m; | |
cin >> m; | |
int px,py; | |
cin >> px >> py; | |
for(int i=1;i<m;i++){ | |
int x,y; | |
cin >> x >> y; | |
l.push_back(P(x,y)-P(px,py)); | |
px = x; py = y; | |
} | |
} | |
P rotate(P p,double theta){ | |
theta = theta * M_PI / 180.0; | |
double x = real(p) * cos( theta ) - imag(p) * sin( theta ); | |
double y = real(p) * sin( theta ) + imag(p) * cos( theta ); | |
return P(x,y); | |
} | |
LL rotate(LL l,double theta){ | |
for(int j=0;j<(int)l.size();j++){ | |
l[j] = rotate(l[j], 90.0); | |
} | |
return l; | |
} | |
bool eqv(P a,P b){ | |
return fabs(a.real()-b.real())<EPS && fabs(a.imag()-b.imag())<EPS; | |
} | |
LL reverse(LL b){ | |
LL r; | |
for(int i=(int)b.size()-1;i>-1;i--){ | |
r.push_back(-b[i]); | |
} | |
return r; | |
} | |
bool check(LL a,LL b){ | |
if( a.size() != b.size() ) return false; | |
for(int i=0;i<4;i++){ | |
bool f=true; | |
for(int j=0;j<(int)a.size();j++){ | |
if( !eqv(a[j],b[j]) ) f=false; | |
} | |
if(f) return true; | |
a = rotate(a,90.0); | |
} | |
return false; | |
} | |
bool isCheck(LL a,LL b){ | |
return check(a,b) || check(a,reverse(b)); | |
} | |
int main(){ | |
while( cin >> N && N ) { | |
A.clear(); | |
inputLine(A); | |
for(int i=0;i<N;i++){ | |
LL B; | |
inputLine(B); | |
if( isCheck(A,B) ) cout << i+1 << endl; | |
} | |
cout << "+++++"<<endl; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment