DFS
kalilili
双眼闭三年。
展开
-
部分和问题
题目表述:给定整数a1,a2,、、、an,判断是否可以从中选出若干数,使他们的和恰好为K;限制条件:1-10^8-10^8c++代码实现如下:#includeusing namespace std;int a[25];int main(){ bool dfs(int i,int sum,int k,int n); int n,k; cin>原创 2014-12-19 20:43:57 · 682 阅读 · 0 评论 -
HDU 5285 wyh2000 and pupil(dfs或种类并查集)
wyh2000 and pupilTime Limit: 3000/1500 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Others)Total Submission(s): 755 Accepted Submission(s): 251Problem DescriptionYoung theoret原创 2015-07-20 11:27:05 · 1533 阅读 · 0 评论 -
HDU 5313 Bipartite Graph(二分图染色+01背包水过)
Problem DescriptionSoda has a bipartite graph with n vertices and m undirected edges. Now he wants to make the graph become a complete bipartite graph with most edges by adding some extra edge原创 2015-07-26 11:30:05 · 1117 阅读 · 0 评论 -
Codeforces Round #311 (Div. 2) E - Ann and Half-Palindrome(字典树+dp)
E. Ann and Half-Palindrometime limit per test1.5 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputTomorrow Ann takes the hardest原创 2015-07-08 13:18:30 · 1097 阅读 · 0 评论 -
FZOJ 2185 树的路径覆盖(YY+DFS)
Problem 2185 树的路径覆盖Accept: 37 Submit: 118Time Limit: 2000 mSec Memory Limit : 32768 KB Problem Description給一棵树, 用最少的路径去覆盖所有的边, 求(1)允许边被重复覆盖, (2)不允许边被重复覆盖. Input第一行是组数原创 2015-03-23 22:59:01 · 853 阅读 · 0 评论 -
CodeForces 525D Arthur and Walls(DIV2 D) (DFS+YY)
D. Arthur and Wallstime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputFinally it is a day when Arthur has eno原创 2015-03-29 09:14:47 · 785 阅读 · 0 评论 -
POJ 2676/2918 数独(dfs)
思路:记录每行每列每个宫已经出现的数字即可,数据比较弱另外POJ 3074 3076 必须用剪枝策略,但实现较麻烦,还是以后学了DLX再来做吧//Accepted 160K 0MS #include#include#include#includeusing namespace std;const int N =15;char sudo[N][N];bool visr[N][原创 2015-03-15 14:55:45 · 787 阅读 · 0 评论 -
POJCurling 2.0(冰壶游戏)(DFS)
Curling 2.0Time Limit: 1000MS Memory Limit: 65536KTotal Submissions: 12490 Accepted: 5265DescriptionOn Planet MM-21, after their Olympic games this year, curlin原创 2015-01-21 20:11:09 · 1622 阅读 · 0 评论 -
POJ2362 Square
题目描述:给定一系列枝条,判断他们是否可以收尾相连接成一个正方形。样例输入:第一行是样例个数N,以下各n行是的第一个数M是这个样例的枝条数,然后后面跟着各个枝条的长度。限制条件:4每个枝条的长度between 1 and 10,000。样例i/o:Sample Input34 1 1 1 15 10 20 30 40 508 1 7 2 6 4 4原创 2014-12-19 21:24:43 · 853 阅读 · 0 评论 -
POJ-1416-Shredding Company(模拟+dfs)
Shredding CompanyTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 4397 Accepted: 2519DescriptionYou have just been put in charge of developing a new sh原创 2015-01-21 22:36:34 · 959 阅读 · 0 评论 -
POJ2488A Knight's Journey(dfs+数学)
A Knight's JourneyTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 32422 Accepted: 11040DescriptionBackground The knight is getting bored of seeing t原创 2015-01-21 19:53:06 · 719 阅读 · 0 评论 -
Channel Allocation(dfs)
Channel AllocationTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 12678 Accepted: 6498DescriptionWhen a radio station is broadcasting over a very la原创 2015-02-02 17:33:19 · 655 阅读 · 0 评论 -
POJ1111 Image Perimeters(求连块周长)
题目描述有一个矩形的由 X 和 . 组成的图像,已知它的长和宽。现在给你一个坐标(保证坐标上是X),求其整个连块的周长。(连块就是连着的X,斜着有相同顶点也算)。输入长,宽,坐标X,坐标Y,接着是图。多组数据,4个0结束。样例输入7 7 4 4XXXXXXXXX...XXX..X..XX..X...X..X..XX.....XXXX原创 2014-12-19 21:15:14 · 1016 阅读 · 0 评论 -
n个数的全排列的相关问题
问题类型:需要进行n个数的全排列再进行其他操作O(2^n)c++代码实现:#includeusing namespace std;int perm[11],pos,n;bool mapp[11]={0};void perm1(int pos,int n){ if(pos==n+1) { for(int k=1;k<=n;k++)原创 2014-12-19 21:51:37 · 1080 阅读 · 0 评论 -
POJ N0.2386 Lake Counting(求连通块数量)
题目描述:有一个大小为N*M的园子,雨后积水。八连通的积水被认为是一个水洼,求园子共有多少水洼。八连通示意图(相对W的连通部分用*标记)* * ** W ** * *限制条件N,M10 12W........WW.. WWW.....WWW....WW...WW..........WW......原创 2014-12-19 22:15:14 · 1030 阅读 · 0 评论 -
Light OJ 1061 - N Queen Again(搜索+状压DP)
大致题意:8*8的棋盘,已知八个皇后的位置,问最少移动多少次,可以让八个皇后不互相攻击。(同行,同列,同斜线视为互相攻击)思路:易知八皇后不攻击一共有92种,dfs出这92种,然后对于每种状压求出最少需要移动多少次复杂度: O( 92 * n * 2 ^ n) (n = 8)//package ok;import java.math.*;import java.io原创 2015-10-30 10:53:14 · 700 阅读 · 0 评论