摘要: 题面:https://www.luogu.org/problem/P3804 cpp 由于i在link[i]处断裂,所以两者的maxlen已经不同,所以我们要将断裂的点重新接上,也就是从link[i]向i建边,最后跑一边dfs统计答案即可。 Code: include include include 阅读全文
posted @ 2019-08-11 08:47 prestige 阅读(142) 评论(0) 推荐(0) 编辑
摘要: 题面:https://www.luogu.org/problem/P4568 cpp 本题是分层图裸题 Code: include include include include include include include include using namespace std; const i 阅读全文
posted @ 2019-08-08 01:58 prestige 阅读(105) 评论(0) 推荐(0) 编辑
摘要: 题面:https://www.luogu.org/problem/P2324 cpp A∗ 的核心思想是一个公式: f(n)=g(n)+h(n) f(n)是代价估值, g(n)是预计估值, h(n)是实际耗费 例如本题,如果你己经动了s步,还有g个骑士未归位,那么如果 s+g 15就可以直接剪枝,因 阅读全文
posted @ 2019-08-08 00:44 prestige 阅读(311) 评论(0) 推荐(0) 编辑
摘要: ```cpp 题目背景 深绘里一直很讨厌雨天。 灼热的天气穿透了前半个夏天,后来一场大雨和随之而来的洪水,浇灭了一切。 虽然深绘里家乡的小村落对洪水有着顽固的抵抗力,但也倒了几座老房子,几棵老树被连根拔起,以及田地里的粮食被弄得一片狼藉。 无奈的深绘里和村民们只好等待救济粮来维生。 不过救济粮的发放 阅读全文
posted @ 2019-08-06 20:30 prestige 阅读(154) 评论(0) 推荐(0) 编辑
摘要: 题面:https://www.luogu.org/problem/P4213 cpp include include include include include include include include include using namespace std; const int mod= 阅读全文
posted @ 2019-08-06 19:27 prestige 阅读(110) 评论(0) 推荐(0) 编辑
摘要: ```cpp Description 小 X 自幼就很喜欢数。但奇怪的是,他十分讨厌完全平方数。他觉得这些数看起来很令人难受。由此,他也讨厌所有是完全平方数的正整数倍的数。然而这丝毫不影响他对其他数的热爱。 这天是小X的生日,小 W 想送一个数给他作为生日礼物。当然他不能送一个小X讨厌的数。他列出了 阅读全文
posted @ 2019-08-06 18:45 prestige 阅读(232) 评论(0) 推荐(0) 编辑
摘要: ```cpp include include include include include include include include using namespace std; const int N=1000005; int n,m,root=1,cnt=1,lson[N],rson[N], 阅读全文
posted @ 2019-08-06 15:31 prestige 阅读(252) 评论(0) 推荐(0) 编辑
摘要: ```cpp include include include include include include include include using namespace std; const int M=5000005; int Cnt,n,m,sum[M 1; lc[t]=build(l,mi 阅读全文
posted @ 2019-08-06 14:58 prestige 阅读(240) 评论(0) 推荐(1) 编辑
摘要: ```cpp include include include include include include include include using namespace std; const int N=205; double x[N],sum[N=r){ cnt[i]+=v; pushup(i 阅读全文
posted @ 2019-08-06 11:23 prestige 阅读(123) 评论(0) 推荐(0) 编辑
摘要: ```cpp #include #include #include #include #include #include using namespace std; long long a,m,b; long long read(long long m){ register long long x=0,f=0; char ch=getchar(); while(!isdigit(c... 阅读全文
posted @ 2019-08-03 22:04 prestige 阅读(242) 评论(0) 推荐(0) 编辑
摘要: ```cpp 混合图(既有有向边又有无向边的图)中欧拉环、欧拉路径的判定需要借助网络流! (1)欧拉环的判定: 一开始当然是判断原图的基图是否连通,若不连通则一定不存在欧拉环或欧拉路径(不考虑度数为0的点)。 其实,难点在于图中的无向边,需要对所有的无向边定向(指定一个方向,使之变为有向边),使整个图变成一个有向欧拉图(或有向半欧拉图)。若存在一个定向满足此条件,则原图是欧拉图(或半欧拉图)否... 阅读全文
posted @ 2019-08-03 16:26 prestige 阅读(707) 评论(0) 推荐(0) 编辑
摘要: 题面:https://www.luogu.org/problem/P1273 阅读全文
posted @ 2019-07-25 12:58 prestige 阅读(118) 评论(0) 推荐(0) 编辑
摘要: 题面:http://poj.org/problem?id=3398 cpp 本题是求树的最小支配集裸题。 Code: include include include include include include include using namespace std; const int N=10 阅读全文
posted @ 2019-07-25 12:41 prestige 阅读(87) 评论(0) 推荐(0) 编辑
摘要: 题面:http://acm.hdu.edu.cn/showproblem.php?pid=1054 cpp 本题是求树的最小点覆盖裸题。 Code: include include include include include include include using namespace std 阅读全文
posted @ 2019-07-25 12:39 prestige 阅读(79) 评论(0) 推荐(0) 编辑
摘要: ```cpp 题目描述 某大学有N个职员,编号为1~N。他们之间有从属关系,也就是说他们的关系就像一棵以校长为根的树,父结点就是子结点的直接上司。现在有个周年庆宴会,宴会每邀请来一个职员都会增加一定的快乐指数Ri,但是呢,如果某个职员的上司来参加舞会了,那么这个职员就无论如何也不肯来参加舞会了。所以 阅读全文
posted @ 2019-07-25 12:37 prestige 阅读(62) 评论(0) 推荐(0) 编辑
摘要: 题面:http://poj.org/problem?id=1655 阅读全文
posted @ 2019-07-25 12:35 prestige 阅读(84) 评论(0) 推荐(0) 编辑
摘要: 题面:http://poj.org/problem?id=2631 阅读全文
posted @ 2019-07-25 12:32 prestige 阅读(67) 评论(0) 推荐(0) 编辑
该文被密码保护。 阅读全文
posted @ 2019-07-24 15:04 prestige 阅读(18) 评论(0) 推荐(0) 编辑
摘要: 题面:https://www.luogu.org/problemnew/show/P3047 cpp Code: include using namespace std; const int root=1,MAXN=100001; struct rec{ int pre,to; }a[2 MAXN] 阅读全文
posted @ 2019-07-24 14:11 prestige 阅读(111) 评论(0) 推荐(0) 编辑
摘要: 题面:https://www.luogu.org/problemnew/show/P3258 cpp 本题中每次所修改路径的终点等于下一次所修改路径的起点,所以每次修改完后要将终点的果子数 1。 Code: include include include include include includ 阅读全文
posted @ 2019-07-24 13:58 prestige 阅读(141) 评论(0) 推荐(0) 编辑
摘要: 题面:https://www.luogu.org/problemnew/show/P3901 cpp Code: include include include include include include include using namespace std; const int N=1000 阅读全文
posted @ 2019-07-24 13:56 prestige 阅读(121) 评论(0) 推荐(0) 编辑
摘要: 题面:https://www.luogu.org/problemnew/show/P2709 cpp 本题的关键在于sum(n)² sum(n 1)²=sum(n)² sum(n)²+2 sum(n) 1=2 sum(n) 1 Code: include include include includ 阅读全文
posted @ 2019-07-24 13:55 prestige 阅读(95) 评论(0) 推荐(0) 编辑
摘要: 题面:https://www.luogu.org/problemnew/show/P2015 cpp 设f[u][i]表示u的子树上保留i条边,至多保留的苹果数目 那么状态转移方程也就显而易见了: f[u][i]=max(f[u][i],f[u][i−j−1]+f[v][j]+e[i].w)( 1≤ 阅读全文
posted @ 2019-07-23 14:19 prestige 阅读(123) 评论(0) 推荐(0) 编辑
摘要: ```cpp 【题目描述】: 有根树在计算机科学工程领域是一个人人熟知的数据结构类型。下面是一个例子。 8 (1,4,5);1 (13,14);4 (6,10);5 (9);6 (7,15);10 (2,11,16);16 (3,12); 在这个图中,每个点都是由{1, 2,...,16}中的某个数 阅读全文
posted @ 2019-07-23 14:15 prestige 阅读(171) 评论(0) 推荐(0) 编辑
摘要: 题面:https://www.luogu.org/problemnew/show/P3178 cpp Code: include include include include include include using namespace std; const long long N=100005 阅读全文
posted @ 2019-07-23 14:14 prestige 阅读(202) 评论(0) 推荐(0) 编辑
摘要: 题面:https://www.luogu.org/problemnew/show/P2590 cpp Code: include include include include include include using namespace std; const int N=100005,INF=1 阅读全文
posted @ 2019-07-23 14:13 prestige 阅读(206) 评论(0) 推荐(0) 编辑
摘要: ```cpp 无向图:因为欧拉路径中,除了起点与终点以外,任意点的“进”“出”次数相等,所以除了两个点为奇点(度数为奇数的点)(终点和起点)以外,其它点的度数均为偶数。 如果是欧拉回路,奇点的个数应该为0。 有向图:欧拉路径中,最多只有两个点的入度不等于出度。起点出度比入度大1,终点入度比出度大1。 如果是欧拉回路,所有点的 入度=出度 。 ``` 阅读全文
posted @ 2019-07-22 00:51 prestige 阅读(799) 评论(0) 推荐(0) 编辑
摘要: ```cpp include include include include include include include include define ls (o 1; down(o); if(ql 1; down(o); if(ql 1,ans =0; down(o); if(ql 阅读全文
posted @ 2019-07-22 00:21 prestige 阅读(536) 评论(0) 推荐(0) 编辑
摘要: ```cpp include include include include include include include using namespace std; const int N=200005; int n,bit,q; long long sum[Nb?a:b; } long long 阅读全文
posted @ 2019-07-18 14:06 prestige 阅读(110) 评论(0) 推荐(0) 编辑
摘要: ```cpp 【题目描述】: 现在请求你维护一个数列,要求提供以下两种操作: 1、 查询操作。 语法:Q L 功能:查询当前数列中末尾L个数中的最大的数,并输出这个数的值。 限制:L不超过当前数列的长度。 2、 插入操作。 语法:A n 功能:将n加上t,其中t是最近一次查询操作的答案(如果还未执行 阅读全文
posted @ 2019-07-18 13:49 prestige 阅读(122) 评论(0) 推荐(0) 编辑
摘要: ```cpp 题目背景 Generic Cow Protests, 2011 Feb 题目描述 约翰家的N 头奶牛正在排队游行抗议。一些奶牛情绪激动,约翰测算下来,排在第i 位的奶牛的理智度为Ai,数字可正可负。 约翰希望奶牛在抗议时保持理性,为此,他打算将这条队伍分割成几个小组,每个抗议小组的理智 阅读全文
posted @ 2019-07-18 13:45 prestige 阅读(131) 评论(0) 推荐(0) 编辑
摘要: 题面:https://www.luogu.org/problemnew/show/P3431 cpp Code: include include include include include include include using namespace std; const int N=1000 阅读全文
posted @ 2019-07-18 13:45 prestige 阅读(84) 评论(0) 推荐(0) 编辑
摘要: ```cpp 【题目描述】: 如题,已知一个数列,你需要进行下面两种操作: 1.将某区间每一个数加上x 2.将某区间每一个数乘上x 3.求出某区间每一个数的和 【输入描述】: 第一行包含三个整数N、M、P,分别表示该数列数字的个数、操作的总个数和模数。 第二行包含N个用空格分隔的整数,其中第i个数字 阅读全文
posted @ 2019-07-18 13:44 prestige 阅读(134) 评论(0) 推荐(0) 编辑
摘要: ```cpp 【题目描述】: 如题,已知一个数列,你需要进行下面两种操作: 1.将某区间每一个数加上x 2.求出某区间每一个数的和 【输入描述】: 第一行包含两个整数N、M,分别表示该数列数字的个数和操作的总个数。 第二行包含N个用空格分隔的整数,其中第i个数字表示数列第i项的初始值。 接下来M行每 阅读全文
posted @ 2019-07-18 13:43 prestige 阅读(125) 评论(0) 推荐(0) 编辑
摘要: ```cpp 奇怪的题目背景 所误入的 是回忆的教室 所响起的 是通向绝望的计时器 所到达的 是开始的结束 你能相信吗? 题目背景 最近礼奈酱学会了线段树和树状数组两种数据结构 由于礼奈酱上课听的很认真,所以她知道 树状数组常见的操作是 单点加区间求和 线段树常见的操作是 区间加区间求和 但她认为自 阅读全文
posted @ 2019-07-17 00:37 prestige 阅读(192) 评论(0) 推荐(0) 编辑
摘要: ```cpp 【题目描述】: 破解了符文之语,小FF开启了通往地下的道路。当他走到最底层时,发现正前方有一扇巨石门,门上雕刻着一幅古代人进行某种活动的图案。而石门上方用古代文写着“神的殿堂”。小FF猜想里面应该就有王室的遗产了。但现在的问题是如何打开这扇门…… 仔细研究后,他发现门上的图案大概是说: 阅读全文
posted @ 2019-07-17 00:14 prestige 阅读(108) 评论(0) 推荐(0) 编辑
摘要: ```cpp Description 如题,已知一个数列(下标从1开始计数),你需要进行下面两种操作: 1.将某区间每一个数,加上x 2.获取某一个数的值 Input 第一行包含两个整数N、M,分别表示该数列数字的个数和操作的总个数。 第二行包含N个用空格分隔的整数,第i个数字表示数列第i项的初始值 阅读全文
posted @ 2019-07-16 23:39 prestige 阅读(77) 评论(0) 推荐(0) 编辑
摘要: ```cpp 【题目描述】: 如题,已知有N个元素组成的数列(下标从1开始计数),你需要进行下面两种操作: 1.将某一个数加上x 2.求出某区间每一个数的和 【输入描述】: 第一行包含两个整数N、M,分别表示该数列数字的个数和操作的总个数。 第二行包含N个用空格分隔的整数,其中第i个数字表示数列第i 阅读全文
posted @ 2019-07-16 22:57 prestige 阅读(125) 评论(0) 推荐(0) 编辑
摘要: ```cpp 【题目描述】: 因为某国被某红色政权残酷的高压暴力统治。美国派出将军uim,对该国进行战略性措施,以解救涂炭的生灵。 该国有n个城市,这些城市以铁路相连。任意两个城市都可以通过铁路直接或者间接到达。 uim发现有些铁路被毁坏之后,某两个城市无法互相通过铁路到达。这样的铁路就被称为key 阅读全文
posted @ 2019-07-16 16:01 prestige 阅读(109) 评论(0) 推荐(0) 编辑
摘要: ```cpp 【题目描述】: 在幻想乡,上白泽慧音是以知识渊博闻名的老师。春雪异变导致人间之里的很多道路都被大雪堵塞,使有的学生不能顺利地到达慧音所在的村庄。因此慧音决定换一个能够聚集最多人数的村庄作为新的教学地点。 人间之里由N个村庄(编号为1..N)和M条道路组成,道路分为两种一种为单向通行的, 阅读全文
posted @ 2019-07-16 16:00 prestige 阅读(161) 评论(0) 推荐(0) 编辑