暑假集训
Lyang0.0
这个作者很懒,什么都没留下…
展开
-
B. Odd Sum Segments(基础数论)
题目地址:http://codeforces.com/contest/1196/problem/BYou are given an arrayaaconsisting ofnnintegersa1,a2,…,an You want to split it into exactlykknon-empty non-intersecting subsegmentssuch that ...原创 2019-08-17 08:59:54 · 685 阅读 · 3 评论 -
O - Snacks(DFS序2)
百度科技园内有nn个零食机,零食机之间通过n−1n−1条路相互连通。每个零食机都有一个值vv,表示为小度熊提供零食的价值。由于零食被频繁的消耗和补充,零食机的价值vv会时常发生变化。小度熊只能从编号为0的零食机出发,并且每个零食机至多经过一次。另外,小度熊会对某个零食机的零食有所偏爱,要求路线上必须有那个零食机。为小度熊规划一个路线,使得路线上的价值总和最大。Input输入数据第...原创 2019-08-10 09:08:05 · 209 阅读 · 0 评论 -
N - Apple Tree(DFS序1)
There is an apple tree outside of kaka's house. Every autumn, a lot of apples will grow in the tree. Kaka likes apple very much, so he has been carefully nurturing the big apple tree.The tree hasN...原创 2019-08-09 20:06:39 · 235 阅读 · 0 评论 -
GCD - Extreme (II) (数论,欧拉函数)
题目的来源:https://vjudge.net/problem/UVA-11426 题目大意:求在1-n之间所有任意两个数的的最大公因数的和。思路概括:假设a、b(a<b)互质,那么gcd(a,b)=1,这样当i循环到a、j循环到b时就会向结果中+1,而i循环到2*a、j循环到2*b时就会向结果中+2(gcd(2*a,2*b)=2)...循环到k*a和k*b时就会向结果...原创 2019-08-14 11:02:17 · 299 阅读 · 0 评论 -
C - Zhenya moves from parents (线段树 + lazy标记)
Zhenya moved from his parents’ home to study in other city. He didn’t take any cash with him, he only took his father’s credit card with zero balance on it. Zhenya succeeds in studies at the Universit...原创 2019-08-09 16:07:21 · 161 阅读 · 0 评论 -
K - Video Reviews(二分)
The studio «Lodka Gaming» is engaged in advertising of their new game «.C.O.N.T.E.S.T: Unexpected Behaviour». The studio's marketer is planning to communicate withnvideobloggers one by one (in the p...原创 2019-08-07 10:48:51 · 350 阅读 · 0 评论 -
E - Harmonic Number 【调和级数 && 欧拉常数】
In mathematics, thenthharmonic number is the sum of the reciprocals of the firstnnatural numbers:In this problem, you are givenn, you have to findHn.InputInput starts with an integerT...原创 2019-08-13 20:32:57 · 330 阅读 · 0 评论 -
E - Text Editor (二分 + KMP)
One of the most useful tools nowadays are text editors, their use is so important that the Unique Natural Advanced Language (UNAL) organization has studied many of the benefits working with them.The...原创 2019-08-13 20:06:16 · 336 阅读 · 0 评论 -
树状数组详解
1.什么是树状数组?顾名思义,就是用数组来模拟树形结构呗。那么衍生出一个问题,为什么不直接建树?答案是没必要,因为树状数组能处理的问题就没必要建树。和Trie树的构造方式有类似之处。2.树状数组可以解决什么问题可以解决大部分基于区间上的更新以及求和问题。3.树状数组和线段树的区别在哪里树状数组可以解决的问题都可以用线段树解决,这两者的区别在哪里呢?树状数组的系数要少...原创 2019-08-09 08:51:16 · 164 阅读 · 0 评论 -
C - A Simple Problem with Integers(树状数组区间修改、区间查询模板)
You haveNintegers,A1,A2, ... ,AN. You need to deal with two kinds of operations. One type of operation is to add some given number to each number in a given interval. The other is to ask for the ...原创 2019-08-09 08:27:58 · 132 阅读 · 0 评论 -
A - Anniversary party(树形DP)
There is going to be a party to celebrate the 80-th Anniversary of the Ural State University. The University has a hierarchical structure of employees. It means that the supervisor relation forms a tr...原创 2019-08-08 20:49:35 · 208 阅读 · 0 评论 -
C - A Simple Problem with Integers(线段树区间更新)
You haveNintegers,A1,A2, ... ,AN. You need to deal with two kinds of operations. One type of operation is to add some given number to each number in a given interval. The other is to ask for the ...原创 2019-07-30 12:37:26 · 99 阅读 · 0 评论 -
Z - Simpsons’ Hidden Talents(扩展KMP 模板题)
Homer: Marge, I just figured out a way to discover some of the talents we weren’t aware we had.Marge: Yeah, what is it?Homer: Take me for example. I want to find out if I have a talent in politics...原创 2019-08-10 14:42:56 · 139 阅读 · 0 评论 -
A - A Secret(扩展KMP)
Today is the birthday of SF,so VS gives two strings S1,S2 to SF as a present,which have a big secret.SF is interested in this secret and ask VS how to get it.There are the things that VS tell:Suff...原创 2019-08-10 16:06:38 · 254 阅读 · 0 评论 -
D - Bridge Automation (dp)
题目链接:https://vjudge.net/problem/Gym-101490D题目大意:由一个桥,有n艘船需要从桥下面过去,对于桥来说,桥升起来需要60秒,降下去需要60秒,对于每艘船来说,必须等到桥完全升起才能通过,通过时间是20秒,如果桥此刻没有升起来,船最多只能等3分钟,就必须走了。桥上面是通汽车的,桥没有完全落下时,汽车是不能走的,现在告诉你每搜船到达的时间,现在问你汽...原创 2019-08-20 17:13:31 · 295 阅读 · 0 评论 -
P1553 数字反转(升级版)(字符串 模拟)
题目链接:https://www.luogu.org/problem/P1553思路概括:找到符号的位置标记,先反转前面的部分,再反转后面的部分真的是改bug改到吐血给大家列几个把我卡掉的样例(血与眼泪的经历)0.0000 -> 0.01234567890/1234567890 -> 987654321/987654321...原创 2019-08-22 09:25:41 · 185 阅读 · 0 评论 -
H - Course recommendation (模拟)
题目链接:https://cn.vjudge.net/problem/Gym-102299H题目大意:n名学生, m门课程,然后给出每个学生学的课程和成绩,然后问跟他最亲密的学生会教他哪一门判断最亲密的条件是 两名学生的共同学习的课程成绩差的平方和开根号如果和你最亲密的学生要教你的课程你已经学过了 输出-1#include<cstdio>#include<...原创 2019-08-21 20:16:59 · 291 阅读 · 0 评论 -
E - How far away ?(lca)
There are n houses in the village and some bidirectional roads connecting them. Every day peole always like to ask like this "How far is it if I want to go from house A to house B"? Usually it hard to...原创 2019-08-16 16:03:52 · 176 阅读 · 0 评论 -
F - Game on Plane (sg函数)
You are givenNNpoints on a plane. These points are precisely the set of vertices of some regularNN-gon. Koosaga, an extreme villain, is challenging you with a game using these points. You and Koosa...原创 2019-08-12 20:31:55 · 288 阅读 · 0 评论 -
D - Round Numbers(数位dp)
The cows, as you know, have no fingers or thumbs and thus are unable to play Scissors, Paper, Stone' (also known as 'Rock, Paper, Scissors', 'Ro, Sham, Bo', and a host of other names) in order to make...原创 2019-08-12 20:18:19 · 135 阅读 · 0 评论 -
P3379 最近公共祖先(LCA 模板)
题目描述如题,给定一棵有根多叉树,请求出指定两个点直接最近的公共祖先。输入格式第一行包含三个正整数N、M、S,分别表示树的结点个数、询问的个数和树根结点的序号。接下来N-1行每行包含两个正整数x、y,表示x结点和y结点之间有一条直接连接的边(数据保证可以构成树)。接下来M行每行包含两个正整数a、b,表示询问a结点和b结点的最近公共祖先。输出格式输出包含M行,每行包含一个...原创 2019-08-16 14:28:30 · 133 阅读 · 0 评论 -
A - LCM from 1 to n (欧拉筛 + 快速幂 + LCM )
Given an integern, you have to findlcm(1, 2, 3, ..., n)lcmmeans least common multiple. For example lcm(2, 5, 4) = 20, lcm(3, 9) = 9, lcm(6, 8, 12) = 24.InputInput starts with an integerT (≤...原创 2019-08-16 09:42:19 · 361 阅读 · 1 评论 -
F - Nearest Common Ancestors(lca + 树上倍增)
题目链接:https://cn.vjudge.net/problem/POJ-1330A rooted tree is a well-known data structure in computer science and engineering. An example is shown below:In the figure, each node is labeled with an ...原创 2019-08-21 08:38:08 · 175 阅读 · 0 评论 -
不要62 (数位dp)
杭州人称那些傻乎乎粘嗒嗒的人为62(音:laoer)。杭州交通管理局经常会扩充一些的士车牌照,新近出来一个好消息,以后上牌照,不再含有不吉利的数字了,这样一来,就可以消除个别的士司机和乘客的心理障碍,更安全地服务大众。不吉利的数字为所有含有4或62的号码。例如:62315 73418 88914都属于不吉利号码。但是,61152虽然含有6和2,但不是62连号,所以不属于不吉利数字之...原创 2019-08-12 10:54:50 · 153 阅读 · 0 评论 -
B - Tree with Maximum Cost(树形DP)
You are given a tree consisting exactly ofnnvertices. Tree is a connected undirected graph withn−1n−1edges. Each vertexvvof this tree has a valueavavassigned to it.Letdist(x,y)dist(x,y)be t...原创 2019-08-12 10:32:07 · 216 阅读 · 0 评论 -
H - 着色方案(状压DP)
有n个木块排成一行,从左到右依次编号为1~n。你有k种颜色的油漆,其中第i种颜色的油漆足够涂ci个木块。所有油漆刚好足够涂满所有木块,即c1+c2+...+ck=n。相邻两个木块涂相同色显得很难看,所以你希望统计任意两个相邻木块颜色不同的着色方案。Input 第一行为一个正整数k,第二行包含k个整数c1, c2, ... , ck。Output 输出一个整数,即方案总数...原创 2019-08-12 09:59:09 · 200 阅读 · 0 评论 -
A - Color the ball(线段树分块1 || 树状数组)
N个气球排成一排,从左到右依次编号为1,2,3....N.每次给定2个整数a b(a <= b),lele便为骑上他的“小飞鸽"牌电动车从气球a开始到气球b依次给每个气球涂一次颜色。但是N次以后lele已经忘记了第I个气球已经涂过几次颜色了,你能帮他算出每个气球被涂过几次颜色吗?Input每个测试实例第一行为一个整数N,(N <= 100000).接下来的N行,每行包括2个整数...原创 2019-08-01 17:08:25 · 125 阅读 · 0 评论 -
B - Argestes and Sequence(分块2)
Argestes has a lot of hobbies and likes solving query problems especially. One day Argestes came up with such a problem. You are given a sequence a consisting of N nonnegative integers, a[1],a[2],...,...原创 2019-08-01 20:03:28 · 144 阅读 · 0 评论 -
D - Group(莫队1)
There are n men ,every man has an ID(1..n).their ID is unique. Whose ID is i and i-1 are friends, Whose ID is i and i+1 are friends. These n men stand in line. Now we select an interval of men to make...原创 2019-08-03 11:02:48 · 139 阅读 · 0 评论 -
F - An Average Game(莫队3)
Alice and Bob has just learned how to find average of some numbers. They got really excited and decided to come up with a game about finding average. The game works like this, at the start of game a s...原创 2019-08-03 11:21:21 · 127 阅读 · 0 评论 -
H - 吉哥系列故事——完美队形II(Manacher2)
吉哥又想出了一个新的完美队形游戏! 假设有n个人按顺序站在他的面前,他们的身高分别是h[1], h[2] ... h[n],吉哥希望从中挑出一些人,让这些人形成一个新的队形,新的队形若满足以下三点要求,则就是新的完美队形: 1、挑出的人保持原队形的相对顺序不变,且必须都是在原队形中连续的; 2、左右对称,假设有m个人形成新的队形,则第1个人和第m个人身高相同,第2个人和第m-...原创 2019-08-03 16:43:17 · 158 阅读 · 0 评论 -
G - Palindrome(Manacher1)
Andy the smart computer science student was attending an algorithms class when the professor asked the students a simple question, "Can you propose an efficient algorithm to find the length of the lar...原创 2019-08-03 16:15:24 · 130 阅读 · 0 评论 -
关灯问题2
Step1 Problem原题现有n盏灯,以及m个按钮。每个按钮可以同时控制这n盏灯——按下了第i个按钮,对于所有的灯都有一个效果。按下i按钮对于第j盏灯,是下面3中效果之一:如果a[i][j]为1,那么当这盏灯开了的时候,把它关上,否则不管;如果为-1的话,如果这盏灯是关的,那么把它打开,否则也不管;如果是0,无论这灯是否开,都不管。现在这些灯都是开的,给出所有开关对所有灯的控制效果...原创 2019-06-14 20:49:39 · 486 阅读 · 0 评论 -
P - Drainage Ditches (最大流)
Every time it rains on Farmer John's fields, a pond forms over Bessie's favorite clover patch. This means that the clover is covered by water for awhile and takes quite a long time to regrow. Thus, Fa...原创 2019-06-14 20:43:29 · 124 阅读 · 0 评论 -
B - Preparing Olympiad (状压+暴力搜索)
You havenproblems. You have estimated the difficulty of thei-th one as integerci. Now you want to prepare a problemset for a contest, using some of the problems you've made.A problemset for the ...原创 2019-06-14 20:38:19 · 248 阅读 · 0 评论 -
SSY and JLBD (简单模拟)
Mahjong is a board game with a long history. But Mahjong has different rules in different city.A deck of mahjong consists of 136 cards. It contains 1-9 card in three suits,and Seven kinds of word ca...原创 2019-05-24 20:58:53 · 993 阅读 · 1 评论 -
Hoppers (dfs)
You are part of an elite hacking group who has just invented a new type of malware, called the hoppers. Hoppers can operate in any high-security computer networks; however, they can only propagate the...原创 2019-05-03 20:38:43 · 393 阅读 · 0 评论 -
Friends (数组模拟大数乘)
Mike has many friends. Here are nine of them: Alice, Bob, Carol, Dave, Eve, Frank, Gloria, Henry and Irene.Mike is so skillful that he can masternnlanguages (aka. programming languages).His nine...原创 2019-05-03 19:31:46 · 197 阅读 · 1 评论 -
Non-Prime Factors(素数筛 + 质因分解)
In many programming competitions, we are asked to find (or count the number of) Prime Factors of an integerii. This is boring. This time, let’s count the number of Non-Prime Factors of an integerii,...原创 2019-05-03 19:26:39 · 370 阅读 · 0 评论 -
I - Girls' research(Manacher3)
One day, sailormoon girls are so delighted that they intend to research about palindromic strings. Operation contains two steps:First step: girls will write a long string (only contains lower case) ...原创 2019-08-03 17:13:13 · 150 阅读 · 0 评论