DFS
_sophon
Brooding renders me prophetic
展开
-
Luogu P1605 迷宫
原题传送门 #include <bits/stdc++.h> using namespace std; int gap_pic[7][7]; int walk_pic[7][7]; int gap_num; int begin_x,begin_y,end_x,end_y; int x,y; int movex[]={1,-1,0,0}; int movey[]={0,0,1,-1};...原创 2019-02-09 20:10:04 · 98 阅读 · 0 评论 -
Luogu P1451 求细胞数量
原题传送门 广搜版 #include <bits/stdc++.h> using namespace std; char mp[105][105]; int movex[]={1,-1,0,0}; int movey[]={0,0,-1,1}; queue< pair<int,int> > q; int cnt; int m,n; void bfs(int ...原创 2019-02-08 19:39:11 · 91 阅读 · 0 评论 -
Luogu P1141 01迷宫
原题传送门 #include <bits/stdc++.h> using namespace std; char mp[1005][1005];//存图 int ans[1005][1005];//存最后答案 bool vis[1005][1005];//记录是否访问过 int n;//边界 int movex[] = { 0,0,-1,1 };//移动 int movey[] = ...原创 2019-02-17 10:32:52 · 87 阅读 · 0 评论 -
Luogu P1433 吃奶酪
原题传送门 #include <bits/stdc++.h> using namespace std; double dis[20][20];//存两点间距离,dis[i][j]表示第i个点到第j个点距离 double point[20][2];//存坐标 bool walk[20];//记录点是否被访问过 int n;//总点数 double ans = 1e9;//距离最小值 ...原创 2019-02-17 15:05:51 · 305 阅读 · 0 评论 -
Luogu P1958 上学路线
原题传送门 DP #include &lt;iostream&gt; int a, b; using namespace std; int map[20][20]; int gap[20][20]; int main() { cin &gt;&gt; a &gt;&gt; b; int inx, iny; int t; cin &gt原创 2019-02-11 20:37:31 · 235 阅读 · 0 评论 -
Luogu P2097 资料分发1
原题传送门 #include <bits/stdc++.h> using namespace std; vector<int> link[100005];//存连接线,link[t]是一个由第t个点所有连接点组成的vector bool vis[100005];//记录是否访问过 int pointNum, linkNum; void dfs(int x) { vis...原创 2019-02-17 20:02:35 · 161 阅读 · 0 评论 -
Luogu P1363 幻想迷宫
原题传送门 #include <bits/stdc++.h> using namespace std; const int N = 1500 + 5; bool mp[N][N]; int vis[N][N][3];//[][][0] x; [][][1] y; [][][2] vis or not int movex[] = { 0,-1,0,1 }; int movey[] = ...原创 2019-02-23 09:35:20 · 89 阅读 · 0 评论 -
Luogu P1074 靶形数独
原题传送门 #include <bits/stdc++.h> using namespace std; struct consult_row_0 {//定义结构体,把行和这一行上0的个数捆绑起来 int row, num_0; }; struct consult_row_0 dic_row_0[10];//查询第几行有几个0 int origin[10][10];//输入的数独 ...原创 2019-02-18 15:16:12 · 73 阅读 · 0 评论 -
Luogu P1135 奇怪的电梯
原题传送门 DFS版 #include <bits/stdc++.h> using namespace std; int N; int num[205]; bool vis[205]; int beg, end; int minn = 0x7f7f7f7f; void dfs(int now, int step) { if (now == end) { minn = min...原创 2019-03-03 13:36:29 · 145 阅读 · 0 评论