https://codeforces.com/contest/1051/problem/D 题意 一个2*n的矩阵,你可以用黑白格子去填充他,求联通块数目等于k的方案数,答案%998244353. 思路 按列dp,定义状态dp[i][j][k]为前i列,有j个联通块,最后一列为k的方案数 处理出列状态之间的转移(会新产生多少个新的联通块) 注意初始化问题 #include<bits/stdc++.h> #define P 998244353 #define ll long long using…
比赛地址 A(水题) 题目链接 题目: 给出一个数组\(a\)并能进行一个操作使得数组元素更改为数组任意其他两元素之和,问是否可以让数组元素全部小于等于\(d\) 解析: 排序后判断最大值是否小于等于\(d\)或者最小的两个值是否小于等于\(d\)即可 #include<bits/stdc++.h> using namespace std; const int maxn = 105; int n, dat[maxn]; int main() { int T; scanf("%d&qu…
D. Merge Equals time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You are given an array of positive integers. While there are at least two equal elements, we will perform the following oper…
题意:给你一个只含\(+\)和\(-\)的字符串,给你一个数\(x\),\(x\)初始为\(0\),随着字符串的遍历会加一减一,现在有\(m\)个询问,每个询问给出一个区间\([l,r]\)表示将这个区间内的字符串去除,得到新的字符串,问遍历新字符串后,\(x\)取到的值最多有多少. 题解:这题的关键是,\(x\)的值是一一变化的,所以从最大值\(mx\)变为\(mi\),最多有\(mx\)-\(mi\)+1个数,根据题意,区间会把字符串分成两段(不考虑两段的情况),前面的一段很好处理,我们用结…
题意:给你两个字符串\(a\)和\(b\),找出它们的\(lcm\),即构造一个新的字符串\(c\),使得\(c\)可以由\(x\)个\(a\)得到,并且可以由\(y\)个\(b\)得到,输出\(c\),如果\(c\)不存在,输出\(-1\). 题解:我们可以根据\(a\)和\(b\)的长度得出\(c\)的长度\(len_c\),而\(len_c\)一定是\(len_a\)和\(len_b\)的倍数, 我们就可以根据这个倍数关系构造出\(c\)(用\(a\)或者\(b\)构造都行,因为假如合法的…
题:https://codeforces.com/contest/1257/problem/E 题意:给定3个数组,可行操作:每个数都可以跳到另外俩个数组中去,实行多步操作后使三个数组拼接起来形成升序. 输出最小操作次数 dp: #include<bits/stdc++.h> using namespace std; ; ]; int a[M]; ///dp[i][0]表示前i个数全属于第一个数组所要花费的最小代价 ///dp[i][1]表示前i个数全属于第一.二个数组所要花费的最小代价 //…
比赛链接: https://codeforces.com/contest/1156 A. Inscribed Figures 题意: 给出$n(2\leq n\leq 100)$个数,只含有1,2,3,分别代表圆,高与底相等的三角形,正方形 $a_{i+1}$在$a_{i}$的里面,$a_{i+1}$的面积尽可能的大 求不同的交点个数 分析: 注意正方形里面一个圆,再里面一个三角形的时候,有一个交点重合 ac代码: #include<bits/stdc++.h> #define ll long…
C. Memory and De-Evolution time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral tr…
I guess there's not much point in reminding you that Nvodsk winters aren't exactly hot. That increased the popularity of the public transport dramatically. The route of bus 62 has exactly n stops (stop 1 goes first on its way and stop n goes last). T…
Educational Codeforces Round 26 困到不行的场,等着中午显示器到了就可以美滋滋了 A. Text Volume time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You are given a text of single-space separated words, consisting of sm…