题目链接:传送门 题目: F. Summer Practice Report time limit per test seconds memory limit per test megabytes input standard input output standard output Vova has taken his summer practice this year and now he should write a report on how it went. Vova has alre…
Summer Practice Report dp[ i ][ 0 ]表示放完前 i 页, 第 i 页最后一段是 0, 0个数的最小值. dp[ i ][ 1 ]表示放完前 i 页, 第 i 页最后一段是 1, 1个数的最小值. 这个转移细节有点多... #include<bits/stdc++.h> #define LL long long #define LD long double #define fi first #define se second #define mk make_pa…
题目: Now that you’ve come to Florida and taken up surfing, you love it! Of course, you’ve realized that if you take a particular wave, even if it’s very fun, you may miss another wave that’s just about to come that’s even more fun. Luckily, you’ve got…
Polycarp is practicing his problem solving skill. He has a list of n problems with difficulties a1,a2,-,an, respectively. His plan is to practice for exactly k days. Each day he has to solve at least one problem from his list. Polycarp solves the pro…
原文链接https://www.cnblogs.com/zhouzhendong/p/UOJ345.html 前言 我真的是越来越菜了,连树形DP都感觉陌生了. 题解 首先,我们来看看在不断生长叶子会发生什么. 第一种:顺着生长方向走. 第二种:在某一个节点的某些子树依次生长,达到他们之间互相消耗的作用. 对于一个子树 x,假设初始情况下,树心在点 x 上,那么在 x 子树中生长若干次之后,树心离开 x,那么我们考虑求出在树心离开 x 之后,能将 x 往 x 子树方向拉的次数的上界 Max[x]…
Wooden Sticks Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 23527 Accepted Submission(s): 9551 There is a pile of n wooden sticks. The length and weight of each stick are known in a…
一.函数调用优化(空间跨度,避免访问内存) 1.大数据求和,使用sum a = range(100000) %timeit -n 10 sum(a) 10 loops, best of 3: 3.15 ms per loop %%timeit ...: s = 0 ...: for i in a: ...: s += i ...: 100 loops, best of 3: 6.93 ms per loop 2.小数据求和,避免使用sum %timeit -n 1000 s = a + b +…
Choosing Points 数学 Integers on a Tree 构造 Leftmost Ball 计数dp+组合数学 Painting Graphs with AtCoDeer tarjan+polya Building Cubes with AtCoDeer 枚举 AtCoDeer and Election Report 贪心 Snuke's Coloring 思维题 Snuke's Coloring 2 线段树+单调栈 Make Them Even 贪心 1D Reversi 模…
A - Minimizing the String solved 题意:给出一个字符串,可以移掉最多一个字符,在所有可能性中选取一个字典序最小的. 思路:显然,一定可以移掉一个字符,如果移掉的字符的后一个字符大于当前字符,那么字典序会变大. 那只需要从左往右,遇到第一个后面的字符大于当前字符的就可以移掉该字符. #include <bits/stdc++.h> using namespace std; #define N 200010 int n; char s[N]; int main()…