上一页 1 ··· 15 16 17 18 19 20 21 22 23 ··· 31 下一页

2016年1月4日

codeforces 463E . Caisa and Tree

摘要: 题目链接 给一棵树, 两种操作, 一种是将点u的权值改为y, 另一种是查询根节点到点u的路径上, gcd(v, u)>1的深度最深的点v。 修改操作不超过50次。 这个题, 暴力可以过, 但是在cf上找到了一个神奇的代码。  如果没有修改, 那么就将询问存起来。 如果有了修改, 就dfs一次, 将之 阅读全文

posted @ 2016-01-04 16:42 yohaha 阅读(225) 评论(0) 推荐(0) 编辑

codeforces 464B Restore Cube

摘要: 题目链接给8个点, 判断这8个点能否组成一个正方体, 如果能, 输出这8个点。 同一个点的x, y, z可以交换。每一个点有6种排列方式, 一个8个点, 暴力枚举出所有排列方式然后判断能否组成正方体。 判断的方法看代码。#include #include #include #include #inc... 阅读全文

posted @ 2016-01-04 15:10 yohaha 阅读(240) 评论(0) 推荐(0) 编辑

poj 2774 Long Long Message 后缀数组

摘要: 题目链接求两个字符串的最长公共子串。将两个字符串连接起来, 然后找height的最大值, 还要注意此时的sa[i]和sa[i-1]不能在同一个串中。#include #include #include #include #include #include #include #include #inc... 阅读全文

posted @ 2016-01-04 12:32 yohaha 阅读(175) 评论(0) 推荐(0) 编辑

spoj 694 Distinct Substrings 后缀数组

摘要: 题目链接求一个字符串中不相同的子串的个数。子串的总数是(n+1)*n/2, 减去height[i]就可以。#include #include #include #include #include #include #include #include #include #include #includ... 阅读全文

posted @ 2016-01-04 11:14 yohaha 阅读(139) 评论(0) 推荐(0) 编辑

poj 3261 Milk Patterns 后缀数组

摘要: 题目链接求可重叠k次的最长子串。二分子串长度x, 将height数组分组, 看是否有一组中的数量大于等于k。 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #... 阅读全文

posted @ 2016-01-04 10:58 yohaha 阅读(139) 评论(0) 推荐(0) 编辑

2016年1月3日

poj 1743 Musical Theme 后缀数组

摘要: 题目链接做出公差后找出最长不重叠子序列的长度。后缀数组的模板, 二分长度k然后将height数组分组, 判断每一组内sa的最大值-sa的最小值是否大于等于k, 如果大于等于k则满足。 1 #include 2 #include 3 #include 4 #include 5 #in... 阅读全文

posted @ 2016-01-03 23:15 yohaha 阅读(142) 评论(0) 推荐(0) 编辑

2016年1月2日

bzoj 2120 : 数颜色 分块

摘要: 题目链接 给一个序列, 两种操作, 一种是将x位置的数改为y, 一种是询问[l, r]之间有多少种不同的数, 数的范围<1e6。 分块, 对于每个数, 记录它前面的和他相同的数的位置, 如果pre[i]<l, 那么ans++, 具体看代码...... #include <iostream> #inc 阅读全文

posted @ 2016-01-02 22:52 yohaha 阅读(155) 评论(0) 推荐(0) 编辑

hdu 3078 Network lca

摘要: 题目链接给一棵树, m个操作, 一共两种操作, 将第x个点的权值改为y, 询问x->y路径上权值第k大的点的权值。暴力的找..... 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #i... 阅读全文

posted @ 2016-01-02 14:55 yohaha 阅读(192) 评论(0) 推荐(0) 编辑

zoj 3195 Design the city lca倍增

摘要: 题目链接给一棵树, m个询问, 每个询问给出3个点, 求这三个点之间的最短距离。其实就是两两之间的最短距离加起来除2.倍增的lca模板#include #include #include #include #include #include #include #include #include #i... 阅读全文

posted @ 2016-01-02 14:27 yohaha 阅读(251) 评论(0) 推荐(0) 编辑

hdu 2874Connections between cities LCA

摘要: 题目链接给n个城市, m条边, q个询问, 每个询问, 输出城市a和b的最短距离, 如果不联通, 输出not connected。用并查集判联通, 如果不连通, 那么两个联通块之间加一条权值很大的边。 然后树链剖分.....#include #include #include #include #i... 阅读全文

posted @ 2016-01-02 13:47 yohaha 阅读(166) 评论(0) 推荐(0) 编辑

上一页 1 ··· 15 16 17 18 19 20 21 22 23 ··· 31 下一页

导航