05 2015 档案
摘要:题目链接 Solution 比较明显的树形DP模型。 首先可以先用一次DFS求出以1为根时,sum[i](以i为子树的根时,满足要求的子树的个数)。 考虑将根从i变换到它的儿子j时,sum[i]产生的变化. 在变化前sum[i]不为0时,可以用求逆元的方法求出新的sum[i]. ...
阅读全文
摘要:题意比较麻烦见题目链接Solution: 非常值得注意的一点是题目给出的范围只有20,而众所周知字母表里有26个字母。于是显然对一个字母进行变换后是不影响到其它字符串的。 20的范围恰好又是常见状压DP的范围,所有状态压缩后用DP[sta]代表对应位的字符串已经满足要求的最小花费。 ...
阅读全文
摘要:题意: 给定一个n个点(nusing namespace std;const int N = 3009;struct edge { int v, ne;} E[N * N q; memset (vis, 0, sizeof vis); dis[k][S] = 0; vis...
阅读全文
摘要:题意: 给出质量为1~n的n个箱子的m对轻重关系,输出一种可能的箱子的质量排列。Solution: 拓扑排序,注意要处理重边。#include #include using namespace std;const int N = 209;queue q;bool G[N][N];int deg...
阅读全文
摘要:题意: 从n个数中选若干个数,使它们的异或和最大。nusing namespace std;int n;long long a[109];int main(){ ios::sync_with_stdio(); cin >> n; long long ans = 0; for...
阅读全文
摘要:题意: 按照给定的条件判断给出的邮箱地址是否合法。Solution: 模拟。需要注意输入中可能包含空格。 空串不能作为symbol,因此prefix也不能包含连续和出现在首尾的'.'#include #include #include using namespace std;int n;st...
阅读全文
摘要:简单的题。直接找题意来就好了。#include #include using namespace std;int s, n, ans;int main() { cin >> s >> n; n -= s; if (n >= 30 * 60) ans++; if (n >=...
阅读全文

浙公网安备 33010602011771号