摘要: 题目链接 阅读全文
posted @ 2018-09-12 11:47 whymhe 阅读(480) 评论(0) 推荐(0)
摘要: #include #include #include #include using namespace std; const int N=2e4+5; const int INF=0x7fffffff; inline int read() { char c=getchar();int num=0; for(;!isdigit(c);c=getchar()); for(... 阅读全文
posted @ 2018-09-12 11:43 whymhe 阅读(112) 评论(0) 推荐(0)
摘要: #include #include #include #include #include #include using namespace std; const int N=5e3+5; int n,m,k; long long p[N]; long long sum[N]; long long dp[N][N]; int main() { scanf("%d%d%d",&n,&m... 阅读全文
posted @ 2018-09-12 11:42 whymhe 阅读(208) 评论(0) 推荐(0)
摘要: 题目背景 这是一道模板题 可以使用bitset,CDQ分治,K-DTree等方式解决。 题目描述 有 nn 个元素,第 ii 个元素有 a_iai​、b_ibi​、c_ici​ 三个属性,设 f(i)f(i) 表示满足 a_j \leq a_iaj​≤ai​ 且 b_j \leq b_ibj​≤bi 阅读全文
posted @ 2018-09-12 11:40 whymhe 阅读(302) 评论(0) 推荐(0)
摘要: #include #include #include #include #include using namespace std; const int N=3e6+5; const int M=1e7+5; inline int read() { char c=getchar();int num=0; for(;!isdigit(c);c=getchar()); fo... 阅读全文
posted @ 2018-09-12 11:40 whymhe 阅读(192) 评论(0) 推荐(0)
摘要: 题目描述 输入输出格式 输入格式: 输入文件名:TRO.IN 输入文件仅有一行,不超过500000个字符,表示一个二叉树序列。 输出格式: 输出文件名:TRO.OUT 输出文件也只有一行,包含两个数,依次表示最多和最少有多少个点能够被染成绿色。 输入输出样例 输入样例#1: 复制 112200201 阅读全文
posted @ 2018-09-12 11:39 whymhe 阅读(189) 评论(0) 推荐(0)
摘要: //P1032 字串变换 #include #include #include #include #include #include #include #include using namespace std; int n; string S,F; string ori[50],to[50]; int LS,LF; struct STA { string s; int a... 阅读全文
posted @ 2018-09-12 11:38 whymhe 阅读(274) 评论(0) 推荐(0)
摘要: 题目描述 某天,Lostmonkey发明了一种超级弹力装置,为了在他的绵羊朋友面前显摆,他邀请小绵羊一起玩个游戏。游戏一开始,Lostmonkey在地上沿着一条直线摆上n个装置,每个装置设定初始弹力系数ki,当绵羊达到第i个装置时,它会往后弹ki步,达到第i+ki个装置,若不存在第i+ki个装置,则 阅读全文
posted @ 2018-09-12 11:37 whymhe 阅读(228) 评论(0) 推荐(0)
摘要: //Pro:P2147 洞穴勘测 #include #include #include #include #include using namespace std; const int N=1e4+5; int c[N][2],f[N]; bool rev[N]; int st[N],t; inline bool get(int x) { return c[f[x]][1]==... 阅读全文
posted @ 2018-09-12 11:36 whymhe 阅读(142) 评论(0) 推荐(0)
摘要: 题目背景 动态树 题目描述 给定n个点以及每个点的权值,要你处理接下来的m个操作。操作有4种。操作从0到3编号。点从1到n编号。 0:后接两个整数(x,y),代表询问从x到y的路径上的点的权值的xor和。保证x到y是联通的。 1:后接两个整数(x,y),代表连接x到y,若x到y已经联通则无需连接。 阅读全文
posted @ 2018-09-12 11:36 whymhe 阅读(227) 评论(0) 推荐(0)
摘要: // luogu-judger-enable-o2 #include #include #include #include using namespace std; const int N=3e5+5; int f[N],c[N][2]; bool rev[N]; int st[N],t; inline bool get(int x) { return c[f[x]][1]==x;... 阅读全文
posted @ 2018-09-12 11:35 whymhe 阅读(170) 评论(0) 推荐(0)
摘要: #include #include #include #include #include using namespace std; const int N=1e4+5; int n,m1,m2; int s[N],prime[N],maxn,t=2,c,ans=0x7fffffff,l; int main() { scanf("%d%d%d",&n,&m1,&m2); f... 阅读全文
posted @ 2018-09-12 11:33 whymhe 阅读(277) 评论(0) 推荐(0)
摘要: //Pro: P3375 【模板】KMP字符串匹配 #include #include #include #include #include using namespace std; const int N=1e6+5; char a[N],b[N]; int nxt[N]; int main() { scanf("%s",a+1); scanf("%s",b+1); ... 阅读全文
posted @ 2018-09-12 11:32 whymhe 阅读(153) 评论(0) 推荐(0)
摘要: 题目描述 根据一些书上的记载,上帝的一次失败的创世经历是这样的: 第一天, 上帝创造了一个世界的基本元素,称做“元”。 第二天, 上帝创造了一个新的元素,称作“α”。“α”被定义为“元”构成的集合。容易发现,一共有两种不同的“α”。 第三天, 上帝又创造了一个新的元素,称作“β”。“β”被定义为“α 阅读全文
posted @ 2018-09-12 11:31 whymhe 阅读(171) 评论(0) 推荐(0)
摘要: 题目背景 感谢hzwer的点分治互测。 题目描述 给定一棵有n个点的树 询问树上距离为k的点对是否存在。 输入输出格式 输入格式: n,m 接下来n-1条边a,b,c描述a到b有一条长度为c的路径 接下来m行每行询问一个K 输出格式: 对于每个K每行输出一个答案,存在输出“AYE”,否则输出”NAY 阅读全文
posted @ 2018-09-12 11:30 whymhe 阅读(290) 评论(0) 推荐(0)
摘要: 题目描述 小Y来到了一个新的城市旅行。她发现了这个城市的布局是网格状的,也就是有n条从东到西的道路和m条从南到北的道路,这些道路两两相交形成n*m个路口 (i,j)(1<=i<=n,1<=j<=m)。 她发现不同的道路路况不同,所以通过不同的路口需要不同的时间。通过调查发现,从路口(i,j)到路口( 阅读全文
posted @ 2018-09-12 11:29 whymhe 阅读(226) 评论(0) 推荐(0)
摘要: 题目描述 给你一棵TREE,以及这棵树上边的距离.问有多少对点它们两者间的距离小于等于K 输入输出格式 输入格式: N(n<=40000) 接下来n-1行边描述管道,按照题目中写的输入 接下来是k 输出格式: 一行,有多少对点之间的距离小于等于k 输入输出样例 输入样例#1: 复制 7 1 6 13 阅读全文
posted @ 2018-09-12 11:28 whymhe 阅读(201) 评论(0) 推荐(0)
摘要: //Pro: P2375 [NOI2014]动物园 //题意:求1 #include #include #include #include using namespace std; const int N=1e6+5; const int mod=1e9+7; int n,len; int nxt[N],num[N]; char s[N]; long long ans; int main... 阅读全文
posted @ 2018-09-12 11:27 whymhe 阅读(223) 评论(0) 推荐(0)
摘要: #include #include #include #include #include using namespace std; inline int read() { char c=getchar();int num=0; for(;!isdigit(c);c=getchar()); for(;isdigit(c);c=getchar()) num=... 阅读全文
posted @ 2018-09-12 11:26 whymhe 阅读(149) 评论(0) 推荐(0)
摘要: Description 轮状病毒有很多变种,所有轮状病毒的变种都是从一个轮状基产生的。一个N轮状基由圆环上N个不同的基原子和圆心处一个核原子构成的,2个原子之间的边表示这2个原子之间的信息通道。如下图所示 N轮状病毒的产生规律是在一个N轮状基中删去若干条边,使得各原子之间有唯一的信息通道,例如共有1 阅读全文
posted @ 2018-09-12 11:25 whymhe 阅读(135) 评论(0) 推荐(0)
摘要: /*一开始以为是个贪心 发现自己太naive了 将每个技术工人拆成n个点,一共拆n*m个,第i个表示倒数第i次修车。 让每辆车向拆出来的点连边,费用为tmp[i][j]*k,i是技工,j是车,k是拆出来的第几个点, 这样设置费用的原因是j是i倒数第k个修的,那么i修的后k个车都要等倒数第k个车。 然后跑最小费用最大流就可以了 */ #include #include #include #i... 阅读全文
posted @ 2018-09-12 11:22 whymhe 阅读(103) 评论(0) 推荐(0)
摘要: #include #include #include #include #include using namespace std; const int N=15; int n; double a[N][N]; int main() { scanf("%d",&n); ++n; for(int i=1;i<=n;++i) { for(int j... 阅读全文
posted @ 2018-09-12 11:21 whymhe 阅读(113) 评论(0) 推荐(0)
摘要: #include #include #include #include #include using namespace std; const int N=15; int n; double a[N][N]; int main() { scanf("%d",&n); ++n; for(int i=1;i<=n;++i) { for(int j... 阅读全文
posted @ 2018-09-12 11:21 whymhe 阅读(104) 评论(0) 推荐(0)
摘要: /************************************************************** Problem: 1011 User: whymhe Language: C++ Result: Accepted Time:1824 ms Memory:2852 kb *************************... 阅读全文
posted @ 2018-09-12 11:20 whymhe 阅读(138) 评论(0) 推荐(0)
摘要: //Pro: 1010: [HNOI2008]玩具装箱toy //因为费用为(X-L)^2,所以我们要让X尽量接近L //对于那些c[]>=L的玩具,显然(列式子算一下)一个玩具一个容器最优 //好的不用分开找规律... //斜率优化DP #include #include #include #include #include using namespace std; typedef ... 阅读全文
posted @ 2018-09-12 11:19 whymhe 阅读(164) 评论(0) 推荐(0)
摘要: /************************************************************** Problem: 1008 User: whymhe Language: C++ Result: Accepted Time:80 ms Memory:1288 kb ***************************... 阅读全文
posted @ 2018-09-12 11:18 whymhe 阅读(156) 评论(1) 推荐(0)
摘要: //因为要求的是从上方看下来可以看到的直线 //画一下图可以发现能看见的是上边的一个下凸壳 //然后就单调栈维护一下斜率就好了 #include #include #include #include using namespace std; const int N=5e4+5; int n; struct LINE { double a,b; int id; }l[N]... 阅读全文
posted @ 2018-09-12 11:16 whymhe 阅读(155) 评论(0) 推荐(0)
摘要: #include #include #include #include #include using namespace std; typedef long long LL; inline int read() { char c=getchar();int num=0;bool f=1; for(;!isdigit(c);c=getchar()) f=c=='... 阅读全文
posted @ 2018-09-12 11:15 whymhe 阅读(167) 评论(0) 推荐(0)
摘要: #include #include #include #include #include using namespace std; const int N=65; int Sr,Sb,Sg,m,p; int fac[N],ifac[N]; int ksm(int x,int k) { int res=1; while(k) { if(k&1) ... 阅读全文
posted @ 2018-09-12 11:14 whymhe 阅读(237) 评论(0) 推荐(0)
摘要: //Pro: 1003: [ZJOI2006]物流运输 //cost[i][j]表示第i天到第j天的最短路长度 //f[i]表示前i天的最小花费 //f[i]=min(f[j-1]+cost[j][i]*(i-j+1)+k) ,j #include #include #include #include #include using namespace std; inline int rea... 阅读全文
posted @ 2018-09-12 11:13 whymhe 阅读(238) 评论(0) 推荐(0)
摘要: /************************************************************** Problem: 1001 User: whymhe Language: C++ Result: Accepted Time:1236 ms Memory:106760 kb ***********************... 阅读全文
posted @ 2018-09-12 11:12 whymhe 阅读(227) 评论(0) 推荐(0)
摘要: #include #include #include #include #include using namespace std; inline int read() { char c=getchar();int num=0; for(;!isdigit(c);c=getchar()); for(;isdigit(c);c=getchar()) num=... 阅读全文
posted @ 2018-09-12 11:11 whymhe 阅读(215) 评论(0) 推荐(0)
摘要: //Pro: P2852 [USACO06DEC]牛奶模式Milk Patterns //后缀数组 //求出现次数>=k的最长可重叠字串的长度 //首先出现次数为k+1的串的长度肯定不大于出现次数为k的串 //所以我们就求出现次数为k次的串 //我们把这个串看成是原串的后缀的前缀 //那么这个串就是k个后缀的前缀 //而且这k个后缀的rnk是连续的 //又因为height[i]记录的是s... 阅读全文
posted @ 2018-09-12 11:10 whymhe 阅读(137) 评论(0) 推荐(0)
摘要: //Pro:P4051 [JSOI2007]字符加密 //我们将字符串复制一遍贴在后面 //然后对这个新字符串跑后缀数组 //令len=原字串的长度 //求出sa[]来后,对于那些sa[i]>len的串,不要他们 //要不然就存下sa[i]+len-1位置的字符 #include #include #include #include #include using namespace st... 阅读全文
posted @ 2018-09-12 11:09 whymhe 阅读(198) 评论(0) 推荐(0)
摘要: #include #include #include #include #include using namespace std; const int N=1e6+5; char s[N]; int n,m; int tax[N],tp[N],rnk[N],sa[N]; inline void Qsort() { for(int i=1;i=1;--i) sa[ta... 阅读全文
posted @ 2018-09-12 11:08 whymhe 阅读(220) 评论(0) 推荐(0)
摘要: 题意翻译 给定一个字符串,求该字符串含有的本质不同的子串数量。 题目描述 Given a string, we need to find the total number of its distinct substrings. 输入输出格式 输入格式: T- number of test cases 阅读全文
posted @ 2018-09-12 11:07 whymhe 阅读(216) 评论(0) 推荐(0)
摘要: //Pro:P4688 [Ynoi2016]掉进兔子洞 //ans= r1-l1+1 + r2-l2+1 +r3-l3+1 - ∑min(cnt1[i],cnt2[i],cnt3[i])*3 //计算cnt可以用莫队 //如何计算cnt的min //用bitset (第一次用这玩意真神奇 //将原数组排个序 //将每个数离散化为它在有序数组中出现的第一个位置 //bitset里的每一位对应... 阅读全文
posted @ 2018-09-12 11:06 whymhe 阅读(256) 评论(0) 推荐(0)
摘要: #include #include #include #include #include using namespace std; const int N=3e3+5; int n; string str; int num; inline char check(string s,int len) { int cnt=0; for(int i=0;i>=1; s=ro... 阅读全文
posted @ 2018-09-12 11:04 whymhe 阅读(190) 评论(0) 推荐(0)
摘要: //Pro:NOIP 2011 P1313 计算系数 //可以用杨辉三角来推 //但是,在这儿给出一个比较麻烦的解法:) //锻炼数学技巧233 //sol: //由二项式定理推出系数,当然了暴力乘的话肯定会炸的,而且不能取模 //所以,把分子和分母上的数存下来,进行质因数分解约分 //质因数分解的话,先筛个素数 //然后再做除法 //然后让系数乘上x的系数a的n次方再乘上y的系数b... 阅读全文
posted @ 2018-09-12 11:03 whymhe 阅读(208) 评论(0) 推荐(0)
摘要: #include #include #include #include #include #include using namespace std; const int N=1e6+5; const int M=2e4; int n; char t[N],p[155][75]; int nxt[M][26]; int id[M],fail[M],last[M]; int now_node;... 阅读全文
posted @ 2018-09-12 11:02 whymhe 阅读(243) 评论(0) 推荐(0)
摘要: //Pro:NOIP2008 T2 P1149 火柴棒等式 #include #include #include #include #include using namespace std; const int N=50; const int stick[N]={6,2,5,5,4,5,6,3,7,6}; int n; int work(int x) { int res=0; ... 阅读全文
posted @ 2018-09-12 11:01 whymhe 阅读(210) 评论(0) 推荐(0)
摘要: //Pro:NOIP2009 T3 P1073 最优贸易 //Sol:先用tarjan缩点,得到一个DAG,然后在DAG上拓扑即可。 #include #include #include #include #include #include #include using namespace std; const int N=1e5+5; const int M=5e5+5; inlin... 阅读全文
posted @ 2018-09-12 11:00 whymhe 阅读(230) 评论(0) 推荐(0)
摘要: 题意翻译 题目大意 一开始有kk种生物,这种生物只能活1天,死的时候有p_ipi​的概率产生ii只这种生物(也只能活一天),询问m天内所有生物都死的概率(包括m天前死亡的情况) 输入格式 第一行输入一个整数TT,表示数据总数 每一组先输入三个整数n(1<=n<=1000),k(0<=k<=1000) 阅读全文
posted @ 2018-09-12 10:59 whymhe 阅读(208) 评论(0) 推荐(0)
摘要: //Pro:NOIP2009 T1 P1071 潜伏者 #include #include #include #include #include using namespace std; const int N=205; char c[N],y[N],to[N]; char ma[N],am[N]; bool f1[N],f2[N]; int cnt; int main() { ... 阅读全文
posted @ 2018-09-12 10:59 whymhe 阅读(306) 评论(0) 推荐(0)
摘要: 题目描述 一个无向连通图,顶点从1编号到N,边从1编号到M。 小Z在该图上进行随机游走,初始时小Z在1号顶点,每一步小Z以相等的概率随机选 择当前顶点的某条边,沿着这条边走到下一个顶点,获得等于这条边的编号的分数。当小Z 到达N号顶点时游走结束,总分为所有获得的分数之和。 现在,请你对这M条边进行编 阅读全文
posted @ 2018-09-12 10:58 whymhe 阅读(159) 评论(0) 推荐(0)
摘要: 题目描述 HanksHanks 博士是 BTBT(Bio-TechBio−Tech,生物技术) 领域的知名专家,他的儿子名叫 HanksonHankson。现在,刚刚放学回家的 HanksonHankson 正在思考一个有趣的问题。 今天在课堂上,老师讲解了如何求两个正整数c_1c1​ 和 c_2c 阅读全文
posted @ 2018-09-12 10:56 whymhe 阅读(169) 评论(0) 推荐(0)
摘要: 题意翻译 「Poetize3」 题目背景 随着新版百度空间的上线,Blog宠物绿豆蛙完成了它的使命,去寻找它新的归宿。 题目描述 给出一个有向无环图,起点为1终点为N,每条边都有一个长度,并且从起点出发能够到达所有的点,所有的点也都能够到达终点。绿豆蛙从起点出发,走向终点。 到达每一个顶点时,如果有 阅读全文
posted @ 2018-09-12 10:55 whymhe 阅读(167) 评论(0) 推荐(0)
摘要: 题目描述 如题,已知一个数列,你需要进行下面三种操作: 1.将某区间每一个数乘上x 2.将某区间每一个数加上x 3.求出某区间每一个数的和 输入输出格式 输入格式: 第一行包含三个整数N、M、P,分别表示该数列数字的个数、操作的总个数和模数。 第二行包含N个用空格分隔的整数,其中第i个数字表示数列第 阅读全文
posted @ 2018-09-12 10:55 whymhe 阅读(162) 评论(0) 推荐(0)
摘要: 题目背景 SDOi2012 题目描述 Longge的数学成绩非常好,并且他非常乐于挑战高难度的数学问题。现在问题来了:给定一个整数N,你需要求出∑gcd(i, N)(1<=i <=N)。 输入输出格式 输入格式: 一个整数,为N。 输出格式: 一个整数,为所求的答案。 输入输出样例 输入样例#1:  阅读全文
posted @ 2018-09-12 10:53 whymhe 阅读(198) 评论(0) 推荐(0)