题目大意:每一个城市都有一定的魅力值,然后有一个有向图,根据这个有向图从1到n+1所获得的魅力的最大值,并输出路径(要求只能从编号娇小的城市到编号较大的城市)。 题解:很容易想到最短路+路径纪录。但是感觉有点小题大做了。我开始的方法是dfs+dp,dp[i]表示i的子节点最大的魅力值,但是它给的是一 ...
分类:
其他好文 时间:
2020-03-18 18:27:29
阅读次数:
50
``` //将含有N个元素的一个集合分成M个子集,使得每个子集的最大值与最小值平方差的和最小。 #include #include #include #include using namespace std; typedef long long ll; const int maxn = 1e4+50... ...
分类:
其他好文 时间:
2020-03-18 18:27:15
阅读次数:
60
题目: 在老式手机上,用户通过数字键盘输入,手机将提供与这些数字相匹配的单词列表。每个数字映射到0至4个字母。给定一个数字序列,实现一个算法来返回匹配单词的列表。你会得到一张含有有效单词的列表。映射如下图所示: 示例 1: 输入: num = "8733", words = ["tree", "us ...
分类:
其他好文 时间:
2020-03-18 17:10:14
阅读次数:
82
拼写单词 题目 给你一份『词汇表』(字符串数组)?words?和一张『字母表』(字符串)?chars。 假如你可以用?chars?中的『字母』(字符)拼写出 words?中的某个『单词』(字符串), 那么我们就认为你掌握了这个单词。 注意:每次拼写时,chars 中的每个字母都只能用一次。 返回词汇 ...
分类:
其他好文 时间:
2020-03-18 15:17:26
阅读次数:
79
题目链接:http://icpc.njust.edu.cn/Problem/Hdu/1711/ 1 #include<bits/stdc++.h> 2 using namespace std; 3 typedef unsigned int ui; 4 typedef long long ll; 5 ...
分类:
其他好文 时间:
2020-03-18 14:05:17
阅读次数:
65
题目网址:http://icpc.njust.edu.cn/Problem/Hdu/2087/ 代码: 1 #include<bits/stdc++.h> 2 using namespace std; 3 typedef unsigned int ui; 4 typedef long long ll ...
分类:
其他好文 时间:
2020-03-18 13:30:23
阅读次数:
57
Given a string str and a dictionary dict, you need to find out which words in the dictionary are subsequences of the string and return those words.The ...
分类:
其他好文 时间:
2020-03-18 10:05:00
阅读次数:
74
题目链接:http://icpc.njust.edu.cn/Problem/Hdu/1732/ 题目就是推箱子游戏,有三个箱子和三个洞,最终目标状态就是三个箱子到三个洞中,所以我们搜索的状态就是人的位置和箱子的位置,因为总共8个状态值,而且横纵坐标的范围也不大,所以我们可以考虑一个8维的数组来存储状 ...
分类:
其他好文 时间:
2020-03-18 09:15:37
阅读次数:
53
题目: 思路: 思路很简单,只要分别统计chars中和每个单词中字母出现的个数,chars中的字母大于等于每个单词中的字母的个数,这个单词便是good 可以利用C++中的map实现,现在记录一种更灵活更常用的方式,凡是要统计字母个数,都可以这样处理: 创建一个数组vec[26],每个位置分别存储的是 ...
分类:
其他好文 时间:
2020-03-17 22:36:19
阅读次数:
75
```#include#include#include#includeusing namespace std;const int MAX = 1000+10;//dp[i][j]:把前 i 个数分成 j 段后能得到的序列的最小权值和//dp[i][j] = min( dp[k][j-1] + cos... ...
分类:
其他好文 时间:
2020-03-17 21:10:27
阅读次数:
49