随笔分类 - dfs
摘要:https://codeforces.com/contest/1316/problem/D 题意:给出n*n的棋盘,每一个格子a[i][j]给出x , y 。 如果x、y不为-1 , 表示该格子要能走到x , y这个格子 。如果为-1 , 表示该格子要无限走。 用 U , D , R , L , X
阅读全文
摘要:题意:n件物品,给你x个箱子,每个箱子的容量为w,问这些箱子能否装下这n件物品。 解法:枚举物品搜索每一个箱子,找到就放没找到就回溯(挪动其他物品)。 优化:1、物品从大到小排序,大的先放下,可以避免多次回溯(挪动)。2、枚举到第 l 个物品时,只需要在前 l 个箱子找合适的箱子,因为最坏的情况就是
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=5925 题意:给你一个无向完全图,求指定大小s个点的完全图子图的个数。 解法:单向建边顺序遍历,避免重复。 #include<stdio.h> #include<string.h> #include<math.h>
阅读全文
摘要:https://codeforces.com/gym/102471/problem/M 题意:给你集合A of {1,2,…,n} , 求子集的最大分数 给出a[1],a[2]...a[n] 和 b[1],b[2]...b[n]. 积分规则: 1、初始分数为0. 2、每一个加入集合的i加上a【i】分
阅读全文
摘要:题意:给你一个二维数组,求最长的递减路线的长度,只能向四个方向延伸。 解法1、dp【i】【j】以i、j结尾的最长路线长度。边界:每个数初值为1, 转移:从四周向i、j转移,if(a[i][j]>a[x][y]) dp[i][j] = max(dp[i][j] , dp[x][y]+1); 注意:这里
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1242 Rescue Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission
阅读全文
摘要:http://codeforces.com/gym/102394/problem/F F. Fixing Banners time limit per test 1 second memory limit per test 512 megabytes input standard input out
阅读全文
摘要:https://codeforces.com/problemset/problem/1249/B2 B2. Books Exchange (hard version) time limit per test 1 second time limit per test memory limit per
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1181 变形课 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Others)Total Submission(s
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=6736 Forest Program Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total
阅读全文
摘要:http://codeforces.com/gym/100989/problem/L L. Plus or Minus (A) time limit per test 1.0 s memory limit per test 256 MB input standard input output sta
阅读全文
摘要:http://poj.org/problem?id=1154 LETTERS Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 9519 Accepted: 4252 Description A single-player game
阅读全文
摘要:http://oj.jxust.edu.cn/contest/problem?id=1563&pid=4 题目描述 Storm有一个m行n列的整数矩阵。 他会从(1,1)开始,顺时针螺旋访问该矩阵,每个元素恰好被访问一次。 请你按Storm的访问顺序输出每个元素。 输入 第一行输入整数t,表示有t组
阅读全文

浙公网安备 33010602011771号