permutation codeforces mystic round

Codeforces Round 910 E

tilian 我们发现可以通过交换相邻两个的方式让字典序小的任意移动 我们目标串t 要是t[0]为 c 我们肯定是找到第一个合法的c的位置 每次去找合法并且最优的 那么哪些是不合法的呢 比如我 比c小的 a,b 位置还在第一个c前肯定就不能用了 我们用26个set维护这个过程即可 void solv ......
Codeforces Round 910

Codeforces Round 909 (Div. 3)

Codeforces Round 909 (Div. 3) A. Game with Integers 题意: 给定一个数\(x\),\(A,B\)两人轮流进行操作,\(A\)先操作。每次给\(x\)加一或者减一,操作完后\(x \% 3 == 0\)者获胜。判断获胜者。 解题思路: 判断\(A\) ......
Codeforces Round 909 Div

codeforces 50题精选训练

本章节参考:2020,2021 年 CF 简单题精选 - 题单 - 洛谷 | 计算机科学教育新生态 (luogu.com.cn) 首先,很容易观察到点的一些特征: - 都在第一象限;- 点的分布越来越稀疏。 以样例为例: 还有无限个点没有画出来。 根据点的分布越来越稀疏的特性,能不能发现收集点的规律 ......
codeforces

Codeforces Round 905 (Div. 3) ABCDEG1

Codeforces Round 905 (Div. 3)ABCDEG1 A. Morning 思路:签到,直接模拟。 // AC one more times // nndbk #include <bits/stdc++.h> using namespace std; typedef long l ......
Codeforces ABCDEG1 ABCDEG Round 905

Educational Codeforces Round 99 (Rated for Div. 2)

https://codeforces.com/contest/1455 很久没有vp了,感觉思维又僵化了 A题直接看样例,直接猜是长度。 B题首先如果是 \(x=\frac{n(n+1)}{2}\),那么就是n 否则如果\(x=\frac{n(n+1)}{2}+y\),分成两类 y=n,ans=n+ ......
Educational Codeforces Round Rated Div

Educational Codeforces Round 156 (Rated for Div. 2) ABCD

Educational Codeforces Round 156 (Rated for Div. 2) ABCD A. Sum of Three 题意:给定正整数 \(n\),判断是否存在正整数 \(a\),\(b\),\(c\) 满足: \(a+b+c=n\)。 \(a\),\(b\),\(c\) ......
Educational Codeforces Round Rated ABCD

Codeforces Round 904 (Div. 2)

\(A. Simple Design\) https://codeforces.com/contest/1884/submission/233628914 \(B. Haunted House\) https://codeforces.com/contest/1884/submission/2336 ......
Codeforces Round 904 Div

Codeforces Round 910 (Div. 2) - D

目录D. Absolute Beauty Codeforces Round 910 (Div. 2) D. Absolute Beauty 观察可知,只要当交换的 \(i\) 和 \(j\) 满足 $ max(a_i, b_i) < min(a_j, b_j)$ 或者 $ min(a_i, b_i) ......
Codeforces Round 910 Div

CodeForces 合集第三弹

这个合集主要是近期的 CodeForces 比赛题。 1898. Codeforces Round 910 (Div. 2) https://codeforces.com/contest/1898 A. Milica and String 很容易发现答案不超过 \(1\),然后分类讨论当前 B 的个 ......
CodeForces

Codeforces Round 785 (Div. 2)

A - Subtle Substring Subtraction /* * __ ~~~~~~~~~~~ ___ * . . ~~// ...... __--~ ~~ * -. \_|// |||\\ ~~~~~~::::... /~ * ___ _ _-~o~ \/ ||| \\ _/~~- * ......
Codeforces Round 785 Div

Codeforces Round 908 (Div. 2)

Preface 补一下之前期中考落下的CF yysy因为这学期又开始断电了,所以除了周五周六晚上的CF可能都不一定会去打,都会以后面补题为主 A. Secret Sport 由于题目保证给出的状态合法,因此直接输出最后一个字符即可 #include<cstdio> #include<iostream ......
Codeforces Round 908 Div

Codeforces Round 910 (Div. 2)

Codeforces Round 910 (Div. 2) 基本情况 做A题的速度比之前快多了,大概20分钟搞定。 B题想了一个贪心错解,想用链表实现,但是不熟练,实现太慢,而且还被hack了。 但是自己hack掉了,造数据上进步。 B. Milena and Admirer 贪心思路 发现一个大于 ......
Codeforces Round 910 Div

Codeforces Round 910 (Div. 2)

\(A. Milica and String\) https://codeforces.com/contest/1898/submission/233431132 \(B. Milena and Admirer\) https://codeforces.com/contest/1898/submis ......
Codeforces Round 910 Div

Codeforces Round 909 (Div. 3)

Codeforces Round 909 (Div. 3) 基本情况 第一次在 CF 上 AC 了超过一道题。(毕竟是Div3) B 题卡住了很久。 D 没有深入思考。 [B. 250 Thousand Tons of TNT](Problem - B - Codeforces) 一开始死活过不了的 ......
Codeforces Round 909 Div

Educational Codeforces Round 13 E

tilian 最开始看错了以为是 可以任意选择两人or选择一人胜出 但题意是 可以选择下一个擂主是谁 考虑dp的话 我们显然需要记录一个state以及当前擂主是谁 转移就是 dp[state][i]=max(dp[state][i],dp[state(1<<j)][j]*a[i][j]+dp[sta ......
Educational Codeforces Round 13

Codeforces Round 909 (Div. 3) A-E

Codeforces Round 909 (Div. 3) A. Game with Integers 题意: 两人轮流操作,可以加一或减一,若结果能被3整除则输出First,否则输出Second 思路: 若n不能被3整除,则第一个人可以直接通过加一或减一使结果被3整除,反之则一定不能 代码: #i ......
Codeforces Round 909 A-E Div

练习记录-cf-Codeforces Round 909 (Div. 3)(A-G)

好久没打div了 然后思维太差 现在被抓回来继续打了QWQ 终于被我逮到一场G数据结构的 ak了 既然ak了就开心地写下题解 别被hack别被hack别被hack 这场挺简单的 之前打的div3都好难qaq A. Game with Integers 题意:给一个数字,两人轮流操作,可以+1或者-1 ......
cf-Codeforces Codeforces Round 909 A-G

题解 P7972【[KSN2021] Self Permutation】

怎么其他两篇题解都是 \(O(n\log n)\) 的,来发一个 \(O(n)\) 做法,当考前复习了。 对原序列建出小根笛卡尔树,节点编号与原序列中的下标相同。记 \(T_u\) 表示以 \(u\) 为根的子树,\(lc(u),rc(u)\) 分别表示 \(u\) 的左儿子和右儿子。 设 \(f_ ......
题解 Permutation P7972 7972 2021

CodeForces 1709F Multiset of Strings

洛谷传送门 CF 传送门 考虑若确定了所有 \(c_s\),如何计算集合最大大小。 下文令原题面中的 \(f\) 为 \(m\)。 发现我们可以类似倒推地确定。比如若 \(n = 3\),\(c_{00} = \min(c_{000}, c_{001})\),\(c_{01} = \min(c_{0 ......
CodeForces Multiset Strings 1709F 1709

CodeForces 1895G Two Characters, Two Colors

洛谷传送门 CF 传送门 要求最大化收益加上支出,又因为每个字符有染红和染蓝两种选择,考虑最小割模型。可以看成是一开始先获得 \(r_i + b_i\) 的收益,然后对于每个 \(0\),连边 \((S, i, b_i), (i, T, r_i)\);对于每个 \(1\),连边 \((S, i, r ......
CodeForces Characters Two Colors 1895G

Educational Codeforces Round 94 (Rated for Div. 2) D. Zigzags 题解

题意 给你一个数组 \(a1,a2…an\) 请计算有多少个四元组 \((i,j,k,l)\) 符合以下条件: \(1 <= i < j < k < l <= n\) \(a_i=a_k \ \&\&\ a_j=a_l\) \(4<=n<=3000,1<=a_i<=n\) \(input\) 2 5 ......
题解 Educational Codeforces Zigzags Round

CodeForces 1895E Infinite Card Game

洛谷传送门 CF 传送门 容易转化成经典的有向图博弈模型。每张牌建一个点,若 \(x\) 能打败 \(y\) 就连一条 \(x \to y\) 的边。入度为 \(0\) 的点为必败态,之后类似拓扑排序倒推即可。 具体就是若存在边 \(u \to v\),若 \(u\) 为必败态则 \(v\) 为必胜 ......
CodeForces Infinite 1895E 1895 Card

CodeForces 1895F Fancy Arrays

洛谷传送门 CF 传送门 看到题目感觉很怪,没有什么很好的直接做的办法。于是考虑容斥,\(\min a_i \le x + k - 1\) 的方案数减去 \(\max a_i < x\) 的方案数即为答案。 前者的方案数是好算的。注意到只要确定了 \(\min a_i\) 和差分数组 \(a_i - ......
CodeForces Arrays 1895F Fancy 1895

CF1542E2 Abnormal Permutation Pairs (hard version) 题解

怎么会有这么离谱的题目啊。 【模板】前缀和优化 dp。 思路 考虑一个基本的东西。 由于要求字典序的限制。 我们可以枚举最长公共前缀计算。 考虑如何求长度为 \(i\) 的排列有 \(j\) 个逆序对的数量。 设 \(dp_{i,j}\)。 \[dp_{i,j}=\sum_{k=0}^{i-1}dp ......
题解 Permutation Abnormal version 1542E

Codeforces Round 907 (Div. 2)

\(A. Sorting with Twos\) https://codeforces.com/contest/1891/submission/232689614 \(B. Deja Vu\) https://codeforces.com/contest/1891/submission/232690 ......
Codeforces Round 907 Div

牛客周赛 Round 19

牛客周赛 Round 19 A. 小红的字符串大小写变换 题意: 小红拿到了一个仅由大小写字母组成的长度为n的字符串,她希望把前k个字母变成大写,后 n−k个字母变成小写,你能帮帮她吗? 代码: #include <bits/stdc++.h> using namespace std ; const ......
Round 19

Codeforces Round 906 (Div. 2)

A. 简单题 B. 简单题 C. 比赛时没做出来,赶着回宿舍,过了几天来补发现很简单秒掉 D. Doremy's Connecting Plan 给定n个结点的图,每个点有一个权值a[i],开始时图上没有边,如果与点i相邻的点(包括点i)的权值的和记为Sum_i. 给定一个常数c,如果 Sum_i+ ......
Codeforces Round 906 Div

Codeforces Round 809 (Div. 2) D1. Chopping Carrots (Easy Version) 题解

题意 Codeforces Round 809 (Div. 2) D1. Chopping Carrots (Easy Version) 给两个整数\(n, k\), 一个数组 \(a\), 要求构造一个同样长度的数组 \(p\), 使得 \(\max\limits_{1 \le i \le n}\ ......
题解 Codeforces Chopping Carrots Version

CodeForces 1452E Two Editorials

洛谷传送门 CF 传送门 考虑枚举其中一个区间取 \([i, i + K - 1]\),考虑对于每个 \(j\) 一次性处理出,区间取 \([j - K + 1, j]\) 多产生的贡献(即以 \(j\) 为右端点)。 对于一个 \([l_k, r_k]\),设其与 \([i, i + K - 1] ......
CodeForces Editorials 1452E 1452 Two

[题解] CF1156E Special Segments of Permutation

Special Segments of Permutation 给你一个排列 \(p\),求有多少个区间 \([l, r]\) 满足 \(p_l + p_r = \max_{i \in [l, r]} p_i\)。 \(n \le 2 \times 10^5\)。 按最大值分治,记当前的分治中心为 ......
题解 Permutation Segments Special 1156E