首页 > 代码库 > 铁代码

铁代码

 1 #include<cstdio> 2 #include<cstdlib> 3 #include<cstring> 4 #include<cmath> 5 #include<iostream> 6 #include<algorithm> 7 #include<vector> 8 #include<stack> 9 #include<queue>10 #include<map>11 #include<set>12 #define mt(a,b) memset(a,b,sizeof(a))13 using namespace std;14 struct point{15     double x,y;16 }p[8],cir[8];17 struct Q{18     int add[4];19     int step;20 }now,pre;21 queue<Q> q;22 bool vis[4444];23 void flag(int ta[]){24     int res=0;25     for(int i=0;i<4;i++){26         res*=10;27         res+=ta[i];28     }29     vis[res]=true;30 }31 bool judge(int ta[]){32     int res=0;33     for(int i=0;i<4;i++){34         res*=10;35         res+=ta[i];36     }37     return vis[res];38 }39 bool isok(int ta[]){40 41 }42 int bfs(){43     mt(vis,0);44     now.step=0;45     mt(now.add,0);46     flag(now.add);47     while(!q.empty()) q.pop();48     q.push(now);49     while(!q.empty()){50         pre=q.front();51         q.pop();52         if(isok(pre.add)) return pre.step;53     }54     return -1;55 }56 int main(){57     int n;58     while(~scanf("%d",&n)){59         while(n--){60             for(int i=0;i<4;i++){61                 scanf("%lf%lf%lf%lf",&p[i].x,&p[i].y,&cir[i].x,&cir[i].y);62             }63             printf("%d\n",bfs());64         }65     }66     return 0;67 }
View Code

 

铁代码