- 博客(58)
- 收藏
- 关注
原创 后缀自动机学习笔记
后缀自动机学习笔记模板https://github.com/Wowkiee/ACM-ICPC/blob/master/Template/String/6. SuffixAutomaton.cpp做题bzoj3277 cf204E建广义后缀自动机,统计每个状态是多少个串的子串。然后每个串的答案是:在自动机上再走一遍,计数一下。参考题解cf316G3统计每个状态在每个串中出现几次。T...
2018-10-25 16:29:46
179
原创 圆方树学习笔记
圆方树学习笔记http://immortalco.blog.uoj.ac/blog/1955TBD做题记录gym101190C代码
2018-10-25 16:28:03
179
原创 使用ubuntu过程中遇到的问题汇总
使用ubuntu过程中遇到的问题汇总1、使用图形界面设置免密码登录之后,改回密码登陆失效解决方案:https://askubuntu.com/questions/211084/how-do-i-get-ubuntu-to-ask-me-for-a-password-at-login-againsudo gpasswd -d username nopasswdlogin...
2018-10-25 16:27:19
226
原创 李超线段树学习笔记
李超线段树学习笔记入门博客模板其实是线段树标记不下传的一个思想。最终的答案应该是查询log个结点得出的。每次更新会将较劣势的线段下传,因为劣势线段最多只会占当前区间的一半,所以只要下传一半即可。...
2018-10-25 16:25:54
282
原创 UVALive 3263 That Nice Euler Circuit
不知道这段代码为什么错#includeusing namespace std;#define fi first#define se second#define pb push_back#define mp make_pair#define rep(i, a, b) for(int i=(a); i<(b); i++)#define sz(a) (int)a.size()#defin
2017-08-09 12:36:18
198
原创 codeforces 798D Mike and distribution
这个做法不会证,但是可以作为以后做不出题的思路,万一A了呢random_shuffle 头文件algorithm,用来对一个元素序列进行随机的重新排序。#include#includeusing namespace std;typedef long long ll;const int N=100005;int a[N],b[N],c[N];int main() { ///
2017-04-28 11:24:27
282
原创 codeforces 798D Mike and distribution
题意:给出数组a[1...n],b[1...n],挑选不超过n/2+1个下标,使得挑选出的下标对应的数之和大于没被挑选出来的。题解:nlogn做法:a数组从大到小排序。以下对排序之后的数组进行操作。(所提到的下标都是排序之后的下标)首先选取下标1。如果n是偶数,下标n也要取。对于剩下的下标,2与3选取(b[2]>b[3])?2:3,4与5....类推对于b数组,这样
2017-04-28 11:13:03
243
原创 codeforces 798C Mike and gcd problem
题意:给出数组a[1...n],能否经过有限次变换使 gcd(a[i])>1 。能的话输出最小变换次数。 变换规则:选取i,a[i]=a[i]-a[i+1],a[i+1]=a[i]+a[i+1]题解:gcd(a[i])>1:特判gcd(a[i])=1:考虑两个数x,y。d=gcd(x-y,x+y),那么即存在p,q,( gcd(p,q)=1 )使得 x-y=pd , x+y=qd
2017-04-27 19:55:55
381
原创 codeforces 798B Mike and strings
能暴力的水题就不要想别的了#include#include#include#includeusing namespace std;const int N=55;string s[N],tmp[N][N];int n,len;void gettmp(int t) { tmp[t][0]=s[t]; for(int i=1;i<len;++i) { tmp[t][i]=
2017-04-27 19:47:11
306
原创 ZOJ 3964 Yet Another Game of Stones(博弈论)
题意:n堆石子。B每次在一堆取正数个。A取石子的数量受堆的限制。堆类型是0:每次取正数个。堆类型是1:每次取奇数个。堆类型是2:每次取偶数个。输出必胜的人。题解:与经典的nim博弈只差在A取个别石子有限制。那么首先考虑A取石子有限制的那几堆。1.ai是奇数,bi=2。A必定取不完,那么最后肯定会剩下一个情景是:只有一堆是1,其他都是0。要么此时A
2017-04-27 17:52:50
744
原创 ZOJ 3494 BCD Code(数位dp+AC自动机)
题意:给定n个串,找出[L,R]中满足条件的数的数量。条件:该数的BCD码不出现n个串中的任意一个。题解:搞懂了AC自动机就变得很简单上了可计算性理论之后对AC自动机的理解:AC自动机其实就是建立一个确定性有穷自动机。任意一个输入的语言从起始节点出发,如果途经终结状态,那么它便包含AC自动机中存的子串。#include#include#includeusing
2017-04-25 20:59:19
396
原创 HDU 4734 F(x)(数位dp)
题意:寻找 [0,B] 中满足条件的数的数量。条件:这个数的weigh题解:数位dp。一开始存了当前状态的weigh和F(A),但是这样MLE了...后来看了题解,发现存的是F(A)-weigh orz#include#includeint fa;int dig[15],d[15][5000],ba[15];int dp(int po,int sum
2017-04-25 20:53:23
193
原创 HDU 3709 Balanced Number(数位dp)
枚举平衡点的位置#include#includetypedef long long ll;int dig[20];ll d[20][20][2000];ll dp(int po,int bal,int sum,bool zero,bool limit) { if(po<0) return sum==0; if(!limit&&!zero&&d[po][bal][sum]!=-
2017-04-25 20:49:39
229
原创 HDU 4352 XHXJ's LIS(数位dp)
题意:寻找 [L,R] 中满足条件的数的数量。条件:把一个数看成字符串,它的LIS若等于k,则满足条件。题解:数位dp。一开始的想法:考虑nlogn的LIS写法,因此状态包含一个长度为10的字符串,由0~9,inf组成。但是需要把字符串映射成int,用到map,复杂度据说太高了。正解:nlogn的LIS写法是维护了一个数组,由0~9,inf组成。那么对于本题,我
2017-04-24 21:32:44
256
原创 codeforces 55D Beautiful numbers( 数位dp )
题意:计算 [L,R] 中能被自己的所有非零dig整除的数的个数。题解:数位dp。一开始的想法是用一个二进制存出现过的dig,维护sum(ll),直到pos虽然最后是看了题解才做出来,但是还要理一下思路。>>对于一个数,它能够被几个数整除的充要条件是它能被这几个数的lcm整除。 1~9的lcm有不超过50种可能,离散化一下就可以。 因此 [二进制的状态数]
2017-04-24 21:23:50
265
原创 ZOJ3963 Heap Partition
初始化for0~N会超时#include #include #include #include #include #include #include #include #include #include using namespace std;typedef long long ll;typedef unsigned long long ull;typedef pai
2017-04-24 17:33:03
506
原创 ZOJ3961 Let's Chat
扫描线思想#include #include #include #include #include #include #include #include #include #include using namespace std;typedef long long ll;typedef unsigned long long ull;typedef pair pii;
2017-04-23 19:23:03
341
原创 HDU 4920 Matrix multiplication(矩阵优化)
题意:矩阵模3乘法。题解:#include#includeconst int N=808;int a[N][N],b[N][N],c[N][N];int main() { int n; while(~scanf("%d",&n)) { ///init memset(c,0,sizeof(c)); ///read for(int i=1;i<=n;+
2017-04-21 16:42:39
265
原创 codeforces 788C The Great Mixing( BFS / dp+bitset优化 )
题意:n(1e3),k(1e6),a1~ak(1e3)。选取最少的ai(可以重复)t个,使得sum(ai)/t/1000==n/1000成立。题解:k(1e6),a1~ak(1e3) --> 数只有1e3个。sum(ai)/t/1000==n/1000 --> sum(ai)==t*n --> sum(ai-n)==0tn,t=abs(ai)+abs(aj)解法一:BFS
2017-04-21 11:37:31
542
原创 codeforces 547D Mike and Fish
547D - Mike and Fish#include#include#includeusing namespace std;const int N=400005;const int ADD=200000;int sz;int last[N],deg[N],col[N];struct E { int u,v,pre;}e[N<<1];void inite()
2017-03-22 18:49:13
380
原创 vim有关
配置set nu si smartindent mouse=a sw=4 ts=4set mp=g++\ -O2\ -Wall\ --std=c++11\ -Wno-unused-result\ %:r.cpp\ -o\ %:rnmap :vs %:r.in nmap :!time ./%:r nmap :w :make
2017-03-12 21:15:48
181
原创 POJ1741 Tree(点分治模板题)
POJ - 1741参考题解:http://blog.youkuaiyun.com/yang_7_46/article/details/9966455题意:给一棵边带权树,问两点之间的距离小于等于K的点对有多少个。题解:!对于一棵有根数,符合条件的路径分为两类!!经过root!!未经过root(存在于子树)!因此可以用分治的思想,先处理完经过根节点的,再处理子树!对
2017-02-28 19:57:29
297
原创 FFT小结
HDU - 1402模板题。#include#include #include#includeusing namespace std;const double PI=acos(-1.0);struct Complex { double x,y;//x+yi Complex(double _x=0.0,double _y=0.0) { x=_x;y=_y; } Co
2017-02-25 10:56:25
309
原创 HDU5885 XM Reserves(FFT建模)
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------HDU - 588
2017-02-24 21:48:17
781
原创 ZOJ3856 Goldbach(FFT)
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------http://acm.
2017-02-10 15:19:05
428
原创 做题记录
//记一下值得记的//20170121POJ3667 Hotel(线段树区间合并)//线段树基本思想//区间合并基本思想cf739C Alyona and towers(线段树区间合并)//想好线段树结点维护的值,处理好区间合并的UP函数,各个函数想清楚了再写
2017-01-21 15:51:11
307
原创 POJ 3666 + codeforces 713C (dp)
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------http://poj.or
2017-01-18 23:12:46
177
原创 codeforces 750E New Year and Old Subsequence(线段树+矩阵建模)
750E New Year and Old Subsequence题意:s[l~r]减少最少的字符数,使得得到的字符串含有2017子序列,不含2016子序列。一共q次查询。题解:个人感觉矩阵建模的题目都有一种状态转移的思想。本题的状态是:0:初始状态1:22:203:2014:2017mat[i][j]表示状态i转移到j的最小代价
2017-01-17 16:01:01
1233
原创 codeforces contest 750
http://codeforces.com/contest/750//---------------------------------------------------------------------------------------------------------------------------------
2017-01-17 15:55:47
208
原创 codeforces 696D Legen...(AC自动机+矩阵快速幂)
696D Legen...题意:n个字符串(价值val[i]),请构造长度为l的字符串,使它的价值最大(子串的价值之和)。题解:配合 POJ 2778食用。http://blog.youkuaiyun.com/qq_32707623/article/details/54574281这题要搞清楚End数组的含义(以该节点结束的字符串的价值)。还
2017-01-16 17:57:43
368
原创 Codeforces Round #362
http://codeforces.com/contest/699http://codeforces.com/contest/696//--------------------------------------------------------------------------------------------------------------------------
2017-01-16 17:51:30
204
原创 POJ 2778 DNA Sequence(AC自动机+矩阵建模)
DNA Sequence题意:给出m个危险字符串,问有多少个长度为n的字符串不包含以上子串。(仅含A,T,C,G四个字符)题解:http://blog.youkuaiyun.com/morgan_xww/article/details/7834801(参考的题解)数字逻辑电路这堂课中的时序逻辑电路设计,有提到状态图。今天发现AC自动机的原理和状态图的设计是差不多的。
2017-01-16 15:24:14
265
原创 ds作业(并查集)
(非常菜的并查集姿势//------------------------------------------------------------------------------------------------------------------------------------------------------------------------
2016-12-28 16:07:35
195
原创 ds作业(优先队列&贪心)
(非常菜的贪心姿势//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
2016-12-28 13:08:32
413
原创 ds作业(hash)
(非常菜的hash姿势//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
2016-12-27 22:07:53
865
1
原创 ds
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------2.2题意:对
2016-12-26 16:34:45
270
原创 codeforces contest 359
http://codeforces.com/contest/359//---------------------------------------------------------------------------------------------------------------------------------------------
2016-12-13 11:50:14
295
原创 codeforces contest 349
http://codeforces.com/contest/349//---------------------------------------------------------------------------------------------------------------------------------------------
2016-12-12 15:32:31
207
原创 (奇怪的暴力)codeforces 731F 354C
731F Video Cards题意:给出数组a[1~n],(1 ≤ ai ≤ 200 000),从中选取一个数作为第一个数。接下来的所有数都要向下降成它的倍数。求解sum最大是多少。题解:#include #include #include #include #include #include #include #include #include #
2016-12-11 09:54:39
362
原创 codeforces contest 355
http://codeforces.com/contest/355//---------------------------------------------------------------------------------------------------------------------------------------------
2016-12-11 09:37:41
249
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人