随笔分类 -  题库—SPOJ

摘要:题意 "题目链接" Sol 这题可以动态dp做。 设$f[i]$表示以$i$为结尾的最大子段和,$g[i]$表示$1 i$的最大子段和 那么 $f[i] = max(f[i 1] + a[i], a[i])$ $g[i] = max(g[i 1], f[i])$ 发现只跟前一项有关,而且$g[i]从 阅读全文
posted @ 2019-02-24 08:54 自为风月马前卒 阅读(415) 评论(0) 推荐(0)
摘要:题意 "题目链接" Sol 广义后缀自动机板子题。。和BZOJ串那个题很像 首先建出询问串的SAM,然后统计一下每个节点被多少个串包含 最后直接拿询问串上去跑就行了 cpp include using namespace std; const int MAXN = 1e6 + 10; int N, 阅读全文
posted @ 2019-02-20 11:43 自为风月马前卒 阅读(274) 评论(0) 推荐(0)
摘要:题意 "题目链接" Sol 发现abcdef是互不相关的 那么meet in the middle一下。先算出abc的,再算def的 注意d = 0的时候不合法(害我wa了两发。。) cpp include define LL long long using namespace std; const 阅读全文
posted @ 2019-01-09 20:45 自为风月马前卒 阅读(342) 评论(0) 推荐(0)
摘要:题意 "题目链接" 题目的意思是给一个数组C,长度为n,每个数字的范围是2^m,然后要求构造一个数组a,满足 1、a[i] % C[i] !=0 ; 2、a[i] 3、a[i] & a[i+1] = 0; Sol 直接dp的话就是先枚举补集的子集,这样的复杂度是$3^n$的 然后补集的子集可以用高位 阅读全文
posted @ 2018-11-05 20:32 自为风月马前卒 阅读(327) 评论(0) 推荐(1)
摘要:题意 Sol 讲过无数次了。。很显然,一个$10^12$的数开方不超过$8$次后就会变为$1$ 因此直接暴力更改即可,维护一下这段区间是否被全改为了$1$ 双倍经验:https://www.luogu.org/problemnew/show/P4145 阅读全文
posted @ 2018-09-02 07:58 自为风月马前卒 阅读(190) 评论(0) 推荐(0)
摘要:题意 Sol 会了GSS1,GSS3就比较无脑了 直接加个单点修改即可,然后update一下 阅读全文
posted @ 2018-08-31 09:07 自为风月马前卒 阅读(455) 评论(0) 推荐(0)
摘要:题意 给出$n$个数,每次询问区间$(l, r)$内最大字段和 Sol 在合并子树的时候,答案仅有四种情况 打四个标记维护即可 查询同理,用类似update的方式合并 注意查询的时候不能按照以前的方式写,因为不知道变量的下界,最稳妥的办法就是判三种情况 阅读全文
posted @ 2018-08-31 09:03 自为风月马前卒 阅读(421) 评论(0) 推荐(2)
摘要:题意 给出一个$n \times m$的网格,每个位置有一个小写字母,初始在$(1, 1)$,每次可以向上下左右走,问走到$(n, m)$的最小花费 设$(x, y)$为当前位置,$(nx, ny)$为下一位置。$s[x][y]$表示$(x, y)$位置的字符。 若$s[x][y] = s[nx][ 阅读全文
posted @ 2018-08-01 19:35 自为风月马前卒 阅读(1047) 评论(0) 推荐(4)
摘要:Little Daniel loves to play with strings! He always finds different ways to have fun with strings! Knowing that, his friend Kinan decided to test his 阅读全文
posted @ 2018-06-28 15:27 自为风月马前卒 阅读(379) 评论(0) 推荐(0)
摘要:You are given a string S which consists of 250000 lowercase latin letters at most. We define F(x) as the maximal number of times that some string with 阅读全文
posted @ 2018-06-27 20:47 自为风月马前卒 阅读(318) 评论(0) 推荐(0)
摘要:A string is finite sequence of characters over a non-empty finite set Σ. In this problem, Σ is the set of lowercase letters. Substring, also called fa 阅读全文
posted @ 2018-06-27 14:45 自为风月马前卒 阅读(388) 评论(1) 推荐(0)
摘要:题目描述 给定一个n个节点的树,每个节点表示一个整数,问u到v的路径上有多少个不同的整数。 输入格式 第一行有两个整数n和m(n=40000,m=100000)。 第二行有n个整数。第i个整数表示第i个节点表示的整数。 在接下来的n-1行中,每行包含两个整数u v,描述一条边(u,v)。 在接下来的 阅读全文
posted @ 2018-06-24 19:37 自为风月马前卒 阅读(505) 评论(0) 推荐(1)

Contact with me