摘要: 安全seed https://stackoverflow.com/questions/12321133/how-to-properly-seed-random-number-generator/54491783#54491783 func Secure() (int64, error) { var 阅读全文
posted @ 2021-02-26 21:51 Drenight 阅读(96) 评论(0) 推荐(0) 编辑
摘要: 对于字符串$S$的前$i$个字符构成的子串,既是它的后缀又是它的前缀的字符串中,它本身除外,最长的长度记作 $next[i]$ 真是精炼的定义 char s[maxn];int n; int fail[maxn]; char t[maxn];int m; int fnd[maxn]; void ge 阅读全文
posted @ 2018-07-10 19:33 Drenight 阅读(131) 评论(0) 推荐(0) 编辑
摘要: 复杂度大约是nloglog 1 //#include<bits/stdc++.h> 2 //#pragma comment(linker, "/STACK:1024000000,1024000000") 3 #include<stdio.h> 4 #include<algorithm> 5 #inc 阅读全文
posted @ 2018-06-01 22:48 Drenight 阅读(200) 评论(0) 推荐(0) 编辑
摘要: 1 #include<bits/stdc++.h> 2 //#pragma comment(linker, "/STACK:1024000000,1024000000") 3 #include<stdio.h> 4 #include<algorithm> 5 #include<queue> 6 #i 阅读全文
posted @ 2018-06-01 22:42 Drenight 阅读(197) 评论(0) 推荐(0) 编辑
摘要: 可以O(n*2^n)算出n位每个mask值所包含子集的二进制码下标的贡献 比如f[5]=a[0]+a[1]+a[4]+a[5]这种的,101包含了000,001,100,101 1 #include<bits/stdc++.h> 2 //#pragma comment(linker, "/STACK 阅读全文
posted @ 2018-05-31 16:26 Drenight 阅读(186) 评论(0) 推荐(0) 编辑
摘要: 写了两小时发现这题没spj,绝望 1 #include<bits/stdc++.h> 2 #include<stdio.h> 3 #include<algorithm> 4 #include<queue> 5 #include<string.h> 6 #include<iostream> 7 #in 阅读全文
posted @ 2018-05-18 22:09 Drenight 阅读(464) 评论(0) 推荐(0) 编辑
摘要: 以为是智商题,想了一天 试着把矩形去重后保留了单调减的长和单调增的宽,推出了一个DP转移方程, 猜是和满足单峰性质试着三分写了一发wa了,果然不是单峰性质的 之后感觉转移方程像一次函数就想到维护凸包,试探性地搜了关键字usaco和斜率优化发现这题果然是。。 然后就学了学斜率优化DP 自己推出来直线的 阅读全文
posted @ 2018-04-17 20:36 Drenight 阅读(216) 评论(0) 推荐(0) 编辑
摘要: 反素数就是1-x中因子数最多的数中最小的数 首先前15个素数的累和就会爆1e18,然后2的60也会爆1e18 反素数一定由不超过15个素数,指数非严格递减生成,这样就有了例题1的搜索框架 例题1:给一个数n,求最小的数x让x的因子数为n 1 //#include<bits/stdc++.h> 2 / 阅读全文
posted @ 2018-03-31 00:02 Drenight 阅读(143) 评论(0) 推荐(0) 编辑
摘要: 通过坐标变换x'=x-y+n和y'=x+y,开大两倍空间就可以用一个两倍大的二维矩阵中 从[x'-a,y'-a]到[x'+a,y'+a]这个子矩阵表示原图中到(x,y)曼哈顿距离小于等于a的菱形区域啦 二维的离散化就是把(x,y)映射到x*n+y这个一维数列上 这题极限空间应该是log(2n)*lo 阅读全文
posted @ 2018-03-30 20:51 Drenight 阅读(253) 评论(0) 推荐(0) 编辑
摘要: 5000+B,调死我了 set里判重居然是用符号比较判的,调出这个问题之后又莫名re,maxn改到3000居然才能跑discuss的样例 后来本机测发现弹了个bad_alloc。。看来以后做题vector不能随便开这么多了,估计改成静态数组每个一个tot就可以maxn30了 1 //#include 阅读全文
posted @ 2018-03-27 11:10 Drenight 阅读(269) 评论(0) 推荐(0) 编辑