The beginning forgot to record, has been WA
The code is neat, and it's cool to watch.
1#include <cstdio>2#include <iostream>3#include <algorithm>4#include <cstring>5#include <cmath>6#include <queue>7#include <map>8 using namespacestd;9 #defineMOD 1000000007Ten Const intinf=0x3f3f3f3f; One Const Doubleeps=1e-5; AtypedefLong Longll; - #defineCL (a) memset (A,0,sizeof (a)) - #defineTS printf ("*****\n"); the Const intmaxn=1005; - intN,m,tt; - intdir[4][2]={0,1,1,0,0,-1,-1,0}; - BOOLVIS1[MAXN][MAXN]; + BOOLVIS2[MAXN][MAXN]; - voidDfsintDxintDyintDdintTxintTyintTD) + { A if(dx==tx&&dy==ty) at { -printf"%d%d\n", dx,dy); - return; - } - BOOLf1=0, f2=0; - intNdd=DD; in intndx=dx+dir[dd][0]; - intndy=dy+dir[dd][1]; to if(ndx<0|| ndx>=n| | ndy<0|| ndy>=n| | Vis1[ndx][ndy]) ndd= (dd+1)%4; +ndx=dx+dir[ndd][0]; -ndy=dy+dir[ndd][1]; the if(ndx<0|| ndx>=n| | ndy<0|| ndy>=n| |Vis1[ndx][ndy]) * { $f1=1;Panax NotoginsengNdx=dx,ndy=dy,ndd=DD; - } the + A intNtd=TD; the intntx=tx+dir[td][0]; + intnty=ty+dir[td][1]; - if(ntx<0|| ntx>=n| | nty<0|| nty>=n| | Vis2[ntx][nty]) ntd= (td-1+4)%4; $ntx=tx+dir[ntd][0]; $nty=ty+dir[ntd][1]; - if(ntx<0|| ntx>=n| | nty<0|| nty>=n| |Vis2[ntx][nty]) - { theF2=1; -Ntx=tx,nty=ty,ntd=TD;Wuyi } the if(f1&&F2) - { Wuprintf"-1\n"); - return; About } $vis1[ndx][ndy]=1; -vis2[ntx][nty]=1; - - DFS (NDX,NDY,NDD,NTX,NTY,NTD); A } + intMain () the { - intI,j,k,ca=1; $ #ifndef Online_judge theFreopen ("1.in","R", stdin); the #endif the intdx,dy,dd,tx,ty,td; the inttot=0; - while(SCANF ("%d", &n)!=eof&&N) in { the cl (VIS1); the cl (VIS2); Aboutscanf"%d%d%d",&dx,&dy,&dd); thescanf"%d%d%d",&tx,&ty,&TD); thevis1[dx][dy]=1; thevis2[tx][ty]=1; + DFS (DX,DY,DD,TX,TY,TD); - } the}
HDU 4741 2013 Hangzhou Division Online Tournament DFS * * *