摘要:
2021PAT秋季甲级考试题解 1001 Arrays and Linked Lists 题意 Let's design a data structure A that combines arrays and linked lists as the following: At the very be 阅读全文
摘要:
显然,根据题目给定的数据,结果是一些森林 对于每个森林都可以取一些数使得答案最大 又因为必须到根都取掉,我们设计状态为f[i][j],表示以i为根,取j个的答案 对于树上跑一个01背包,然后对于整个森林跑一下分组背包 #include<bits/stdc++.h> using namespace s 阅读全文
摘要:
转化题目,题目要求的是K级祖先,我们可以对于每个询问先跳到祖先,那么就是求对于这个祖先,depth[u]+k的个数是多少个,然后-1就是答案 #include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair 阅读全文