C. A Twisty Movement time limit per test1 second memory limit per test256 megabytes Problem Description A dragon symbolizes wisdom, power and wealth. On Lunar New Year's Day, people model a dragon with bamboo strips and clothes, raise them with rods,…
C. A Twisty Movement time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output A dragon symbolizes wisdom, power and wealth. On Lunar New Year's Day, people model a dragon with bamboo strips and clot…
题目意思: 给长度为n(n<=2000)的数字串,数字只能为1或者2,可以将其中一段区间[l,r]翻转,求翻转后的最长非递减子序列长度. 题解:求出1的前缀和,2的后缀和,以及区间[i,j]的最长不递增子序列. f[i][j][0]表示区间i-j以1结尾的最长不递增子序列: f[i][j][1]表示区间i-j以2结尾的最长不递增子序列,显然是区间i-j 2的个数: 所以转移方程为: f[i][j][1] = f[i][j-1][1] + (a[j]==2);   f[i][j][0] = max…
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] ans初值值为a[1..n]中1的个数. 接下来考虑以2为结尾的最长上升子序列的个数. 枚举中间点i. 计算1..i-1中1的个数cnt1. 计算i..n中2的个数cnt2. ans = max(ans,cnt1+cnt2) 写个前缀和 翻转. 断点在l..r中 f[l][r]表示l..r翻转后以2结尾的最长上升子序列 简单DP ans = max(ans,cnt[l-1][1]+f[l][r]+cnt[n][2]-cnt[r]…
B. A Prosperous Lot time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Apart from Nian, there is a daemon named Sui, which terrifies children and causes them to become sick. Parents give their…
这是我打的第三场cf,个人的表现还是有点不成熟.暴露出了我的一些问题. 先打开A题,大概3min看懂题意+一小会儿的思考后开始码代码.一开始想着贪心地只取两个端点的值就好了,正准备交的时候回想起上次A题被hack的惨痛经历,“这题一定有坑!”.我又想了一会儿,发现每个数都可以是负数,那这样的话我就要取4个端点的值比较了.改了一下就交上去了,过了pretest,直接锁了. 点看B题,看懂题意后觉得这题特别水.1min打了个代码交了上去,结果没过pretest? 后来发现我读快了,没有注意到n必须是…
D. A Determined Cleanup time limit per test1 second memory limit per test256 megabytes Problem Description In order to put away old things and welcome a fresh new year, a thorough cleaning of the house is a must. Little Tommy finds an old polynomial…
A. A Compatible Pair time limit per test1 second memory limit per test256 megabytes Problem Description Nian is a monster which lives deep in the oceans. Once a year, it shows up on the land, devouring livestock and even people. In order to keep the…
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 设\(设f(x)=a_d*x^{d}+a_{d-1}*x^{d-1}+...+a_1*x+a_0\) 用它去除x+k 用多项式除法除一下就好. 会发现余数等于 \(∑_0^{d}(-k)^{i}*a_i\) 这是一个十进制数转成负k进制数的和的形式. 而p已知. 问题就转化为把十进制数p转成-k进制数的问题了. [代码] #include <bits/stdc++.h> #define ll long long using n…
Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate it n = int(raw_input()) s = "" a = ["I hate that ","I love that ", "I hate it","I love it"] for i in ran…