![](https://img-blog.csdnimg.cn/20201014180756724.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
dfs
文章平均质量分 58
wwt9b15bs
这个作者很懒,什么都没留下…
展开
-
【题解】洛谷P1463(同bzoj1053/LibreOJ10203)[POI2002][HAOI2007]反素数 唯一分解定理+dfs
题目链接 题目描述 对于任何正整数x,其约数的个数记作g(x)。例如g(1)=1、g(6)=4。 如果某个正整数x满足:g(x)>g(i) 0 < i < x,则称x为反质数。例如,整数1,2,4,6等都是反质数。 现在给定一个数N,你能求出不超过N的最大的反质数么? 输入输出格式 输入格式: 一个数N(1<=N&am原创 2018-09-11 13:37:27 · 258 阅读 · 0 评论 -
【题解】洛谷P1092[NOIP2004]虫食算 dfs
题目链接 参考了大佬题解中的剪枝操作 #include<cstdio> #include<map> #include<cstdlib> using namespace std; int n,vis[27]; char s[4][27]; map<char,int>mp; void dfs(int x,int y,int jw)//x列y行进位...转载 2018-10-17 11:46:25 · 286 阅读 · 0 评论 -
【题解】codeforces293B[AHSOFNU codeforces训练赛2 by hzwer]D.Distinct Paths dfs+剪枝+位运算
题目链接 Description You have a rectangular n × m-cell board. Some cells are already painted some of k colors. You need to paint each uncolored cell one of the k colors so that any path from the upper lef...转载 2018-09-30 10:10:46 · 150 阅读 · 0 评论 -
【题解】洛谷P3958[NOIP2017]奶酪 并查集/dfs
打了一份并查集一份dfs的代码 #include<cstdio> typedef long long ll; const int N=1e3+10; int set[N]; ll n,h,r; struct node{ ll x,y,z; }hole[N];//存点 void init()//初始化代表元全为自己 { for(int i=0;i<=n+1;i+...原创 2018-10-08 11:09:57 · 589 阅读 · 0 评论 -
【题解】洛谷P1605迷宫 dfs
题目链接 #include <bits/stdc++.h> using namespace std; void dfs(int,int); int pace[4][2]={{0,1},{1,0},{0,-1},{-1,0}};//向右、向下、向左、向上 int a[100][100],book[100][100]; int n,m,t,sx,sy,fx,fy,tx,ty,tota...原创 2018-10-05 19:00:19 · 277 阅读 · 0 评论 -
【题解】洛谷P1101单词方阵 dfs
题目链接 #include<cstdio> #include<iostream> using namespace std; const char cmp[7]="izhong"; const int nx[]={0,1,1,1,-1,-1,-1,0},ny[]={1,1,0,-1,1,0,-1,-1}; int n,vis[110][110]; char s[110]...原创 2018-10-05 18:54:08 · 204 阅读 · 0 评论 -
【题解】洛谷P1164小A点菜 dfs
题目链接 #include<bits/stdc++.h> using namespace std; int num,n,m,a[105],f[10500]; void dfs(int x,int y){ if((x>n)||(y>m)) return; if(y+a[x]==m) num++; dfs(x+1,y); dfs(x+1,y+a[x]); } int...原创 2018-10-12 09:21:15 · 147 阅读 · 0 评论 -
【题解】牛客OI周赛1-提高组 A.分组 dfs
链接:https://www.nowcoder.com/acm/contest/199/A 来源:牛客网 将认识关系转化为图中的边。dfs这张图,对每一个没有被访问过的点,将它标记为源点的反色,回溯的时候统计每个点有多少同色相邻点,个数等于2时将其颜色转换。 #include<cstdio> #include<cstring> const int N=1e5+10,M...原创 2018-10-02 13:23:28 · 378 阅读 · 0 评论 -
【题解】洛谷P1019[NOIP2000T3]单词接龙 dfs
题目链接 题目描述 单词接龙是一个与我们经常玩的成语接龙相类似的游戏,现在我们已知一组单词,且给定一个开头的字母,要求出以这个字母开头的最长的“龙”(每个单词都最多在“龙”中出现两次),在两个单词相连时,其重合部分合为一部分,例如 beastbeastbeast 和 astonishastonishastonish,如果接成一条龙则变为 beastonishbeastonishbeastonish...原创 2018-09-25 07:51:16 · 191 阅读 · 0 评论 -
【题解】洛谷P1219[USACO Training Section 1.5] 八皇后 dfs
题目链接 题目描述 检查一个如下的 6×66\times66×6 的跳棋棋盘,有六个棋子被放置在棋盘上,使得每行、每列有且只有一个,每条对角线(包括两条主对角线的所有平行线)上至多有一个棋子。 上面的布局可以用序列 222 444 666 111 333 555 来描述,第 iii 个数字表示在第 iii 行的相应位置有一个棋子,如下: 行号 111 222 333 444 555 666 列号 ...原创 2018-09-24 22:51:47 · 357 阅读 · 0 评论 -
【题解】codeforces1029E[Codeforces Round #506 (Div. 3)]E.Tree with Small Distances 优先队列+dfs
题目链接 Description You are given an undirected tree consisting of nnn vertices. An undirected tree is a connected undirected graph with n−1n−1n−1 edges. Your task is to add the minimum number of edges i...原创 2018-09-24 20:57:40 · 345 阅读 · 0 评论 -
【题解】洛谷P2668(P2540)[NOIP2015]斗地主(增强版) 线性DP+dfs
题目链接 终于看明白了大佬题解,然而还是各种错误。 #include<cstdio> #include<cstring> #include<algorithm> using namespace std; #define _rep(i,a,b) for(int i=(a);i<=(b);i++) int t,n,ans,dp[25][25][2...转载 2018-11-03 13:47:27 · 458 阅读 · 0 评论