Round

Codeforces Round 871 (Div. 4)

A.Love Story 题意: 给定n个长度为10的字符串,问其与codeforces字符串的对应下标字母不同的个数。 分析: 对于每个字符串从前往后依次和“codeforces”对应字符比较然后统计不同字母数即可 code: #include <bits/stdc++.h> using name ......
Codeforces Round 871 Div

Codeforces Round 871 (Div. 4)

Codeforces Round 871 (Div. 4) A - Love Story #include<bits/stdc++.h> using namespace std; typedef pair<int,int>PII; typedef pair<string,int>PSI; const ......
Codeforces Round 871 Div

Codeforces Round 871 (Div. 4) 题解

好久没打比赛了啊 qwq A~C skip D 把能被 $3$ 整除的数丢到一个队列里去 $\text{BFS}$,每次取队头把它分成两个,如果能被 $3$ 整除继续入队。最后看给定的数有没有入过队。 E 直接 $\text{BFS}$,把每个块总和算出来求最大。 F 可以发现,图的点数 $n=1+ ......
题解 Codeforces Round 871 Div

Codeforces Round 870 (Div. 2)

Codeforces Round 870 (Div. 2) A - Trust Nobody 思路:枚举每一种说谎人数x,若a[i]大于x则说谎人数加一,判断最后说谎总人数是否为x,若是则输出x,结束枚举;若没有满足的x则-1 #include<bits/stdc++.h> using namesp ......
Codeforces Round 870 Div

Codeforces Round 848 (Div. 2)C

B. The Forbidden Permutation 一定要注意题目中说的是对于all i满足才算不好的,我们做的时候只要破坏一个i这个a就不算好的了,被这一点坑了,没注意到all。 #include <bits/stdc++.h> using namespace std; typedef lo ......
Codeforces Round 848 Div

Codeforces Round 856 (Div. 2)C

C. Scoring Subsequences 思路:我们想要找到满足的最大值的长度最长的的区间,因为单调不减,所以更大的数一定在最大值的里面包含,所以我们用两个指针维护这样一个满足当前i的最大值区间,当新来一个数,这时我们答案里面一定要包含这个数,我们看能否保持这个长度,能不能保持需要看j指针所指 ......
Codeforces Round 856 Div

练习记录-cf-div2-Codeforces Round 870 (A-D)

这次写的也是比较快!rank305 虽然D简单,但是写出来了就算胜利! A. Trust Nobody 题意:给出n个人,他们会说多少人是说谎的,你要找出这个人数 思路: n最多只有100个,我枚举说谎的人有i个,对说话小于等于i的做前缀和,这个几个人都是说真话,记录前缀和sum,n-sum就是说谎 ......
Codeforces cf-div Round 870 A-D

Codeforces Round 870 (A-D)

A $n^2$暴力推,遍历可能撒谎的人数(0-n),然后$O(n)$check就行了。 仔细看逻辑其实$O(1)$就能check,草率了,后面再修正 点击查看代码 #include <bits/stdc++.h> #define rep(i, l, r) for(int i = l; i <= r; ......
Codeforces Round 870 A-D

CodeTON Round 4 (Div. 1 + Div. 2)C

C. Make It Permutation 我们希望尽可能少地进行操作可以使代价最小,我们如果要排列的话,那些重复的元素我们无论如何都要进行删除的,所以我们可以先把去重的代价计算出来,然后依次枚举排列的位数是多少,也就是枚举去重后的数组,其中的代价我们可以一次计算出来,当我们枚举第i个a时,前面1 ......
Div CodeTON Round

Educational Codeforces Round 147 (Rated for Div. 2) (贪心)

###原题链接:https://codeforces.com/contest/1821/problem/D * 题意:从1开始走,走的给定区间的值要k次。且shift按了要松开,代表走了一个区间除了往右的次数,还要多两次按shift的次数, 求最小次数。 * 思路: 1. 先把不可能的情况列出来,就 ......
Educational Codeforces Round Rated 147

Codeforces Round 869 (Div. 2)

从这一篇开始,比较重要的题目我会把题面放上 A. Politics 傻逼题目,傻逼题面,傻逼出题人 明明一句话能说清楚的事情为啥放样例了说啊? 不然你说这个东西有多项式解法吗? 一句话题解,和我不同意见的,都得死 #include <bits/stdc++.h> #define ll long lo ......
Codeforces Round 869 Div

Codeforces Round 867 (Div. 3)

A. TubeTube Feed 分析: 从所有a[i]+i-1<=t的选择种取个max即可 code: #include <bits/stdc++.h> using namespace std; const int N = 55; int a[N], b[N]; int main() { std: ......
Codeforces Round 867 Div

SMU Spring 2023 Trial Contest Round 10

A. Remove Duplicates #include <bits/stdc++.h> //#define inf 0x3f3f3f3f #define endl '\n' #define int long long using namespace std; const int N = 2e3 ......
Contest Spring Round Trial 2023

CQ 周赛 Round#1

题目见此 F. 树染色方案计数 一道很有意思的树形 dp,和 P4516 潜入行动 非常相似。 考虑状态怎么定义。第一个维度肯定是以 $i$ 为根的子树,第二个维度是当前子树中的特殊节点个数,同时还要考虑当前节点的颜色,即为第三个维度。 当前节点的颜色无非跟 $k$ 有关,即小于 $k$,等于 $k ......
Round CQ

Deltix Round, Spring 2021 (open for everyone, rated, Div. 1 + Div. 2)

好久没发博客了,发一篇。 A 求出每个 $0$ 与往前 / 往后最近的 $1$ 的距离即可。 时间复杂度 $\mathcal{O}(n)$。 B $(x, y) \to (x + y, y) \to (x + y, -x) \to (y, -x) \to (y - x, -x) \to (y - x ......
Div everyone Deltix Spring Round

SMU Spring 2023 Contest Round 1

SMU Spring 2023 Contest Round 1 B - Contest Preparation 思路:特判下m大于n的情况,只有make后才能validate #include<bits/stdc++.h> using namespace std; typedef pair<int, ......
Contest Spring Round 2023 SMU

Codeforces Round 869 (Div. 2) A-D题解

比赛地址 A. Politics 题意:有n个人对m个决案进行投票,对于每一个决案如果票数相同则所有人都离场,反之票数少的一方离场,现在提前知道了每个人的意见,让一些人参与投票,在保证第一个人不离场的情况下最终剩余人数最多是多少 Solution 把和第一个意见不同的给去掉就行了 void solv ......
题解 Codeforces Round 869 A-D

Chemistry Experiment Codeforces Round 247 (Div. 2) 线段树动态开点,二分

第一次写的时候还不会线段树的动态开点,写了一个是线段树但是是$O(N^2)$的写法,现在用动态开点武装了自己,会了正解$O(qlog n^2)$。首先建立一个权值线段树,但这里的权值很大,通过动态开点去建树来节省空间,对于两种操作: 操作1,常见的动态开点的单点修改 操作2,二分答案,然后在线段树上 ......

Educational Codeforces Round 147 (Rated for Div. 2) A~E 题解

A Link。 模拟,代码。 B Link。 模拟,代码。 C Link。 我们设 $c$ 为最后相同的字符。 性质:我们一定不会删除字符 $c$。 因此以 $c$ 为最后字符的操作次数就是不包含字符 $c$ 的极大段的最小操作次数的最大值。 对于一个长度为 $l(l\ge 1)$ 的段,它的最小操 ......
题解 Educational Codeforces Round Rated

Codeforces Round 868 (Div. 2)

题目链接 C 核心思路 一定要看清楚题目,题目是要我们最小哦。 首先看可不可抽像为数学表达式,答案肯定是可以的。 x=p1^d1*p2^d2*..*pn^dn; D=\sum{(d1+1)*(d2+1)*(d3+1)*...(*(dn+1))}; 这个D表示的x的约数的个数,这个公式还是很好理解的, ......
Codeforces Round 868 Div

Codeforces Round 869 (Div. 1)

C 根据初中数学知识,恒成立问题考虑未知数x每一项的系数,然后得到(d+1)个等式,根据前两个就可以推出$s=\frac{b_{d-1}-a_{d-1}}{da_d}$且$a_d=b_d$ 但是一直不会用题目给的n个点值求出最高的两项系数(或它们的比值),并且怀疑是否把(d+1)个等式全部用到会更好 ......
Codeforces Round 869 Div

Codeforces Round 869 (Div. 2) A-C

A. Politics 思路 与第 $1$ 个人的意见不同的人都要删除 代码 #include<bits/stdc++.h> using namespace std; int main() { int T; cin>>T; while(T--) { int n,m; cin>>n>>m; strin ......
Codeforces Round 869 A-C Div

Codeforces Round 869 (Div. 2)

Preface 一把回到紫名还是很舒服的,D题手比较稳猜了点性质水过 主要还是C脑抽了想了挺久才看出来是个丁真题,不然最后过了D之后30min可以看看E的 由于要写学校的图论专题所以接下来一段时间的CF补题计划就要先停一停了 A. Politics 傻逼题,当某个人的串和第一个人有任意一个位置不同时 ......
Codeforces Round 869 Div

Codeforces Round 823 (Div. 2)C

C. Minimum Notation 思路:我们可以进行的操作时将一个位置的数删除然后在任意位置处添加一个比当前数大1并且小于9的数,所以我们的操作只会让一个数变大,我们统计一个最大值的后缀,贪心的考虑如果当前数的后面有比他小的数的话,我们就需要让这个小的数往前走才能使字典序变小,如果当前值小于< ......
Codeforces Round 823 Div

Codeforces Round 867 (Div. 3)

题目链接 E 核心思路 首先我们先考虑什么情况下是肯定不可以交换成功的: aaabc.比如像这种a的个数超过了我们整个字符串一半的长度就肯定是不可以的。然后剩下的情况肯定都是可以的。 然后考虑怎么样可以使得交换次数最小呢: aa aa bb cc dd ff。 我们发现这组的话我们只需要交换两次,也 ......
Codeforces Round 867 Div

Codeforces Round 869 (Div.1 & Div.2) 题解

2A. Politics 因为编号为 $1$ 的人一定不会离开,那么最后留下的人一定要和编号为 $1$ 的人的所有参数都一致,所以计数即可。 #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext ......
题解 Codeforces Div Round 869

Codeforces Round 825 (Div. 2)——B

#include<bits/stdc++.h> using namespace std; typedef long long ll; #define endl "\n" inline int gcd(int a, int b) { return b > 0 ? gcd(b, a % b) : a; ......
Codeforces Round 825 Div

Codeforces Round 863 (Div. 3)———E

题意:给定一个k,问由012356789组成的数字第k大的是多少 链接:Problem - E - Codeforces #include<bits/stdc++.h> using namespace std; typedef long long ll; #define endl "\n" /* 思 ......
Codeforces Round 863 Div

Codeforces Round 855 (Div. 3)--E

题意: 给定一个k,可以任意次交换满足 | i - j | = k 或 | i - j |=k+1 的两个位置的元素 很容易发现有区间内的字符是可以任意交换的,但是一个个字符考虑太混乱了(就是这样子把脑袋搞晕了),从左考虑那么(1,n - k)这个区间可以任意交换,从右考虑(k + 1, n)这个区 ......
Codeforces Round 855 Div

Codeforces Round 855 (Div. 3)--D

题意: 给定一个字符串,删除其中连续两个字符,问有多少种不同字符串的情况 #include<bits/stdc++.h> using namespace std; typedef long long ll; #define endl "\n" //开始时假设每个点都对答案有贡献,考虑什么时候没有贡献 ......
Codeforces Round 855 Div