上一页 1 ··· 129 130 131 132 133 134 135 136 137 ··· 182 下一页
摘要: 题意不好理解,其实是最小生成树。View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;#define maxn 2005#define inf 0x3f3f3f3fint n;char code[maxn][10];int cost[maxn][maxn];int vis[maxn];int lowc[maxn];int cal(int a, int b){ int ret = 0; for (in 阅读全文
posted @ 2011-06-15 12:18 undefined2024 阅读(776) 评论(0) 推荐(0)
摘要: 1.理解了rmq的st算法。就是将每个大区间用刚好大于其长度一半的2^x的大小来将其分割为两个有重叠区间求解。即s~t被分为s~s + 2^x 和 t - 2^x + 1 ~t。吉大的第一个st是错误的。2.学会了笛卡尔树,即一个满足堆的大小性质的二叉搜索树,但不一定是完全二叉树。这是将rmq转为lca的关键。3.scanf的用法,%*[ ],表示越过[ ]中的字符,%[a-z]表示读入字符串,直到遇到不是a-z中的字符为止。%[^a]表示读入字符串直到遇到字符a为止,但a并没有被读入。题意:给出一些节点,每个节点有两个值,lable和priority(都是唯一的),要求构成一个笛卡尔树,按l 阅读全文
posted @ 2011-06-15 10:39 undefined2024 阅读(883) 评论(2) 推荐(0)
摘要: 搜索,注意0是NOView Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;int fac[20];bool f[1000005];int tot;void dfs(int i, int sum){ if (sum > 1000000) return; f[sum] = true; if (i == tot) return; dfs(i + 1, sum + fac[i]); dfs(i + 1, 阅读全文
posted @ 2011-06-14 20:51 undefined2024 阅读(159) 评论(0) 推荐(0)
摘要: 动态规划,可以把序列计算的所有过程中的得到的结果都%k,这样就可以大大缩小了空间与时间。View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;bool f[2][205];int main(){ //freopen("t.txt", "r", stdin); int n, k; scanf("%d%d", &n, &k); 阅读全文
posted @ 2011-06-14 20:13 undefined2024 阅读(164) 评论(0) 推荐(0)
摘要: 题意:给出一段只有音高(整数表示),没有节奏的乐谱,问其中最长的曲调相同的没有重叠的两段的长度是多少。分析:后缀数组,一定要注意,吉大的模板的nlogn算法,要初始化n=strlen(s) +1,另外,s,sa,rank一定要从0位置开始使用。height从1位置开始有意义。这题是要在求出相邻音高之差之后找不重叠(无公共部分)的最长的重复出现过至少两次的串,也就是在height数组中找到一个连续段,其各项均大于d且sa数组中的对应段中最大值最小值之差要大于d。找到最大的d即可。d符合一个性质,就是小的d都满足,大的d都不满足。用二分法找分界线即可。View Code #include #inc 阅读全文
posted @ 2011-06-14 19:48 undefined2024 阅读(1137) 评论(0) 推荐(0)
上一页 1 ··· 129 130 131 132 133 134 135 136 137 ··· 182 下一页