给定一个数组,找出最长的子序列,满足 a,a,..a,b,b,..b,a,a,..a 前面的a和后面的a都要是x个,中间的b是y个. 其中,x>=0且y>=0. \(\color{Red}{---------------------华丽分割线w(゚Д゚)w------------------------}\) 看到这数据,就觉得暴力无疑. \(三种情况\) \(Ⅰ.当x=0,也就是只有中间部分,答案就是出现次数最多的那个数字.\) \(Ⅱ.当y=0,也就是只有两边的部分,那就要枚举前半部分区间…
题意: 取一字符串不相交的前缀和后缀(可为空)构成最长回文串. 思路: 先从两边取对称的前后缀,之后再取余下字符串较长的回文前缀或后缀. #include <bits/stdc++.h> using namespace std; bool ok(const string &s,int l,int r){ while(l<=r&&s[l]==s[r]) ++l,--r; return l>r; } void solve(){ string s;cin>&…
G1 - Into Blocks (easy version) 参考:Codeforces Round #584 - Dasha Code Championship - Elimination Round (rated, open for everyone, Div. 1 + Div. 2) G1. Into Blocks (easy version) 思路:先把数据预处理一遍,找到每一种数的最右端的位置,和每一种数的出现的次数,然后,从第一个数字开始遍历,用r保存当前这一块的最大右端,用MAX…
任意门:http://codeforces.com/contest/1118/problem/F1 F1. Tree Cutting (Easy Version) time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You are given an undirected tree of nn vertices. Some vert…
F1. Pictures with Kittens (easy version) 题目链接:https://codeforces.com/contest/1077/problem/F1 题意: 给出n个数,以及k,x,k即长度为k的区间至少选一个,x的意思是一共要选x个,少一个或者多一个都不行. 选一个会得到一定的奖励,问在满足条件的前提下,最多得到多少的奖励. 题解: 简单版本数据量比较小,考虑比较暴力的动态规划. dp[i,j]表示前i个数,要选第i个数,目前选了j个所得到的最大奖励,那么当…
CF1225B1 TV Subscriptions (Easy Version) 洛谷评测传送门 题目描述 The only difference between easy and hard versions is constraints. The BerTV channel every day broadcasts one episode of one of the kk TV shows. You know the schedule for the next nn days: a seque…
D1. Kirk and a Binary String (easy version) 01串找最长不降子序列 给定字符串s,要求生成一个等长字符串t,使得任意l到r位置的最长不降子序列长度一致 从后往前暴力枚举,枚举每个一替换成0后是否改变了l到r位置的最长不降子序列长度 01串的最长不降子序列,可以通过线性dp求解 dp i表示以i结尾的最长不降子序列长度 dp[0]=dp[0]+s[i]=='0'; dp[1]=max(dp[0],dp[1])+s[i]=='1'; #include<bi…
http://codeforces.com/problemset/problem/1216/E1 E1. Numerical Sequence (easy version) time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The only difference between the easy and the hard ver…
B. Ping-Pong (Easy Version) time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output In this problem at each moment you have a set of intervals. You can move from interval (a, b) from our set to in…
3868 - Earthstone: Easy Version Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%lld & %llu Submit Status Practice ZOJ 3867 Description Earthstone is a famous online card game created by Lizard Entertainment. It is a collectible card g…