Isomorphic Inversion
Isomorphic InversionLet $s$ be a given string of up to $10^6$ digits. Find the maximal $k$ for which it is possible to partition $s$ into $k$ consecutive contiguous substrings, such that the $k$ parts form a palindrome. More precisely, we say that strings s_0,s_1,…,s_{k−1} form a palindrome if s_i=s_{k−1−i} for all 0\le i< k.
In the first sample case, we can split the string 652526 into $4$ parts as 6|52|52|6, and these parts together form a palindrome. It turns out that it is impossible to spli ...
Aizu 1634 Balance Scale
Balance Scale时间限制 : 8 sec
空间限制 : 262144 KB
题目链接
You, an experimental chemist, have a balance scale and a kit of weights for measuring weights of powder chemicals.
For work efficiency, a single use of the balance scale should be enough for measurement of each amount. You can use any number of weights at a time, placing them either on the balance plate opposite to the chemical or on the same plate with the chemical. For example, if you have two weights of 2 and 9 units, you can measure out not on ...
牛客多校10 J Wood Processing
时间限制:C/C++ 3秒,其他语言6秒空间限制:C/C++ 524288K,其他语言1048576K64bit IO Format: %lld
题目描述In the wood industry, it is very common to make big wood boards by combining planks. To combine several planks into boards, the carpenter may cut some of the planks horizontally and discard one of the two parts, such that the heights of all planks are equal. Then, the planks are joined together, forming a big wood board. The height of the board is the common height of the planks, and the width of the board is the sum ...
P2015 二叉苹果树
P2015 二叉苹果树题目描述有一棵苹果树,如果树枝有分叉,一定是分2叉(就是说没有只有1个儿子的结点)
这棵树共有 $N$ 个结点(叶子点或者树枝分叉点),编号为1-N,树根编号一定是1。
我们用一根树枝两端连接的结点的编号来描述一根树枝的位置。下面是一颗有4个树枝的树
123452 5 \ / 3 4 \ / 1
现在这颗树枝条太多了,需要剪枝。但是一些树枝上长有苹果。
给定需要保留的树枝数量,求出最多能留住多少苹果。
输入格式第1行2个数,$N$ 和 $Q$($1\leq Q\leq N,1<N\leq100$)。
$N$ 表示树的结点数,$Q$ 表示要保留的树枝数量。接下来 $N-1$ 行描述树枝的信息。
每行3个整数,前两个是它连接的结点的编号。第3个数是这根树枝上苹果的数量。
每根树枝上的苹果不超过30000个。
输出格式一个数,最多能留住的苹果的数量。
输入输出样例输入 #1
123455 21 3 11 4 102 3 203 5 20
输出 #1
121
解决方案:啊,树形dp入门题,按照深度优先的顺序去遍历树,在过程 ...
cf 579E Boxers
E. Boxers
time limit per test:2 secondsmemory limit per test:256 megabytesinput:standard inputoutput:standard output
There are $n$ boxers, the weight of the $i-th$ boxer is $a_i$. Each of them can change the weight by no more than $1$ before the competition (the weight cannot become equal to zero, that is, it must remain positive). Weight is always an integer number.
It is necessary to choose the largest boxing team in terms of the number of people, that all the boxers’ weights in the team are ...
POJ 2373 Dividing the Path
Dividing the Path
友情链接:POJ - 2373
Farmer John’s cows have discovered that the clover growing along the ridge of the hill in his field is particularly good. To keep the clover watered, Farmer John is installing water sprinklers along the ridge of the hill.
To make installation easier, each sprinkler head must be installed along the ridge of the hill (which we can think of as a one-dimensional number line of length L ($1\leq L\leq1,000,000$); L is even).
Each sprinkler waters the ground along ...
2019杭电多校7 1006-Final Exam
Final ExamTime Limit: 4000/2000 MS (Java/Others)
Memory Limit: 524288/524288 K (Java/Others)
Problem DescriptionFinal Exam is coming! Cuber QQ has now one night to prepare for tomorrow’s exam.
The exam will be a exam of problems sharing altogether m points. Cuber QQ doesn’t know about the exact distribution. Of course, different problems might have different points; in some extreme cases, some problems might worth 0 points, or all m points. Points must be integers; a problem cannot have 0.5 poin ...
P1886 滑动窗口
题目描述现在有一堆数字共N个数字($N \leq 10^6$),以及一个大小为k的窗口。现在这个从左边开始向右滑动,每次滑动一个单位,求出每次滑动后窗口中的最大值和最小值。
例如:
The array is [1 3 -1 -3 5 3 6 7], and k = 3.
输入格式输入一共有两行,第一行为n,k。
第二行为n个数(<INT_MAX).
输出格式输出共两行,第一行为每次窗口滑动的最小值
第二行为每次窗口滑动的最大值
输入输出样例输入 #1
128 31 3 -1 -3 5 3 6 7
输出 #1
12-1 -3 -3 -3 3 33 3 5 5 6 7
说明/提示50%的数据, $ n \leq 10^5 $
100%的数据,$ n \leq 10^6 $
前几天听肖大佬提到了单调队列,特来补题,不过似乎单调队列用的没有单调栈那么多:-)
思路:
维护两个单调的双端队列:
一个单调递增,该队列的最左端即为当前区间的最小元素。入队一个元素时,若队尾的元素>=当前元素,则它们对最小值毫无贡献,可直接弹出,直到队列为空或碰到比当前元素小的。然后队列左端也要把id ...
POJ 3554 Almost the shortest route
题面
描述:
N cities (2 ≤ N ≤ 10 000 ) are connected by a network of M one-way roads (1 ≤ M <100 000 000 ). It is known that these roads do not cross outside the cities. The numeration of the cities and the roads starts from 1.There is at most one road from any city to another one. The length of each road does not exceed 10 000 .
The company for which you work sends you on a business trip from city 1 to city N on your personal car. The trip expenses will be compensated to you only if the distance ...
如何搭建个人博客
本菜鸡第一次写博客,希望能够坚持下去XD感觉搭建个人博客还是有点麻烦的
步骤大概如下
首先得有一个github账号,创建一个Repository,名字就是username.github.io,创建之后可以在setting里面选择主题,之后就可以通过 https://username.github.io 来访问你的个人博客了!!
这一步比较麻烦,我们一般是在本地用markdown写完博客之后,通过一些工具转化成html和css,再上传到自己的github的username.github.io这个Repository里.
首先要把Node.js,Git,Typora都下载安装好,搭建好相应的环境
既然要远程上传至github的对应仓库下,就得用Git和github配置好ssh,这一步相对来说麻烦点,而且需要一点学习成本(你得学会Git常用的一些命令,这里推荐廖雪峰的教程,花上一个小时,把前面的几个命令学一下就差不多入门了),这方面网上的资料很多。
下载完Node.js之后,在Git中使用命令
1$ nmp install hexo -g
来下载hexo,这是一款用于 ...