http://www.lydsy.com/JudgeOnline/problem.php?id=1074
Test instructions: At the beginning there is a top left corner is (0,100), the lower right corner is (100,0) of the paper, can now be folded along a straight line n times (n<=8, right fold to the left), after folding, there is M inquiry (m<=50), each time asked a point in the final figure through a few pieces of paper.
#include <cstdio> #include <cstring> #include <cmath> #include <string> #include <iostream > #include <algorithm> #include <queue> #include <set> #include <map> #include <sstream >using namespace Std;typedef long long ll; #define PB Push_back#define Rep (i, n) for (int i=0; i< (n); ++i) #define For1 (i,a,n) for (int i= (a), i<= (n), ++i) #define FOR2 (i,a,n) for (int i= (a);i< (n), ++i) #define FOR3 (i,a,n) for (int i= (a); I >= (n); i) #define FOR4 (i,a,n) for (int i= (a);i> (n); i) #define CC (i,a) memset (i,a,sizeof (i)) #define READ (a) a= Getint () #define PRINT (a) printf ("%d", a) #define DBG (x) cout << (#x) << "=" << (x) << Endl#define Error (x) (! ( x) puts ("error"): 0) #define RDM (x, i) for (int i=ihead[x]; i; i=e[i].next) inline int getint () {static int r, K; r=0,k=1; St Atic Char C; C=getchar (); for (; c< ' 0 ' | | C> ' 9 '; C=getchar ()) if (c== '-') k=-1; for (; c>= ' 0 ' &&c<= ' 9 '; C=getchar ()) r=r*10+c-' 0 '; return k*r; }const Double eps=1e-6, Pi2=acos ( -1) *2;int dcmp (double x) {return abs (x) <eps?0: (x<0?-1:1); }struct IP {double x, y; IP (double _x=0, double _y=0): X (_x), Y (_y) {} void Rd () {scanf ("%lf%lf", &x, &y);} void D () {printf ("x=%.2f, y=%.2f\n", X, y);}}; typedef IP IV;IV operator-(IP A, IP b) {return IV (a.x-b.x, a.y-b.y);} IV Operator* (iv A, double b) {return IV (a.x*b, a.y*b);} IV operator+ (IP A, iv b) {return IP (a.x+b.x, a.y+b.y);} BOOL operator== (IP A, IP b) {return dcmp (a.x-b.x) ==0 && dcmp (A.Y-B.Y) ==0;} BOOL operator< (const IP &a, const IP &b) {return a.x==b.x?a.y<b.y:a.x<b.x;} Double Cross (iv A, IV b) {return a.x*b.y-a.y*b.x;} Double Dot (iv A, IV b) {return a.x*b.x+a.y*b.y;} Double Length (IV a) {return sqrt (dot (A, a));} Double Angle (iv A, IV b) {return ACOs (dot (A, b)/length (a)/length (b)); IV Rot (iv V, double ang) {double Cs=cos (ANG), Sn=sin (ANG); return IV (V.X*CS-V.Y*SN, V.Y*CS+V.X*SN);} struct IL {IP p; iv v; IL () {} il (IP _p, IV _v):p (_p), V (_v{}};bool OnL (IP A, IL l) {return dcmp (cross (A-L.P, L.V)) <0;} BOOL OnR (IP A, IL l) {return dcmp (cross (A-L.P, L.V)) >0;} IP rev (IP A, iL l, int flag=1) {return L.p+rot (A-L.P, Angle (A-L.P, L.V) *2*flag);} const int MX=1<<10;IP h[mx];il line[10];int N, M, cnt;void dfs (int dep, IP p) {//if (dcmp (p.x) <=0 | | dcmp (P.X-100) >=0 | | DCMP (p.y) <=0 | | DCMP (p.y-100) >=0) return;h[cnt++]=p;if (dep==0) Return;dfs (Dep-1, p), if (OnL (p, LINE[DEP])) DFS (Dep-1, rev (P, line[ DEP],-1));} IP find (IP p) {for1 (i, 1, N) if (OnR (p, line[i]) P=rev (P, Line[i]), else if (!onl (p, line[i)) return IP ( -1,-1); return p;} BOOL Check (IP &p) {if (dcmp (p.x) <=0 | | dcmp (p.x-100) >=0 | | dcmp (P.Y) <=0 | | dcmp (P.Y-100) >=0) return false; return true; }void work (IP &p) {//if (dcmp (p.x) <=0 | | dcmp (p.x-100) >=0 | | dcmp (P.Y) <=0 | | dcmp (P.Y-100) >=0) {puts ("0") ; Return }int Ans=0;cnt=0;dfs (n, p); sort (h, h+cnt), Cnt=unique (H, h+cnt)-h;rep (i, CNT) if (check (H[i]) && find (H[i]) ==p) + +ans;printf ("%d\n", ans); int main () {read (n); For1 (i, 1, n) {IP P1, p2;p1.rd (); P2.rd (); Line[i]=il (P1, p2-p1);} Read (m); For1 (i, 1, m) {IP p; p.rd (); work (P);} return 0;}
This question is very god ....
See the puzzle is simply shocked qaq reverse thinking ...
First of all, for each point, let's take a look at what points this point might be transferred from (a subset of origami operations sorted in origami order), at most only $2^8$ points. Finally we enumerate the points to see if we can retrace the original points. (Note that if the point being judged at the time of the fold is in this line, then this is no solution, because crossing the boundary does not count.) And there will never be a part of the square covered here.
But I'm stuck in the hole where the computational geometry is not being debugged ... Think of a problem seems to think 2h.................................................sb wrong 1: Calculate the angle between vectors I let forget to play ACOs ... Several times ... sb error 2: Output debug long time, waste a lot of time ... (Can't you think about it ...)
The state is too poor for a problem.
"Bzoj" 1074: [SCOI2007] Origami Origami