permutation codeforces mystic round

CodeForces 1526F Median Queries

洛谷传送门 CF 传送门 首先,如果我们确定了 \(1, 2\) 或 \(n - 1, n\) 的位置,我们就能求出原排列。因为题目给了 \(p_1 < p_2\),所以可以不考虑对称性。也就是说我们知道两个位置是 \(1, 2\) 或 \(n - 1, n\) 但不确定究竟是 \(1, 2\) 还 ......
CodeForces Queries Median 1526F 1526

Codeforces Round 904 (Div. 2)

B. Haunted House 自己写的两个都T了。。没找出问题 思路就是对于i,右面i位中1的pos和为sum1,个数为cnt,那么维护剩余位中最近的cnt个0的pos和为sum0,答案就是sum1-sum0。 jiangly:被 \(2^i\) 整除即最后 \(i\) 位必须是0。一定是把最右 ......
Codeforces Round 904 Div

Codeforces Round 878 (Div. 3)

Codeforces Round 878 (Div. 3) A:ABC A. Cipher Shifer 题意:在自身后面添加一个字母,但是不能添加自身 思路:找到第二个与自身相符的就再找 #include <bits/stdc++.h> using namespace std; const int ......
Codeforces Round 878 Div

[Codeforces] CF1627B Not Sitting

题意 Rahul 和 Tina 在玩一个游戏。游戏在一个 \(n\times m\) 的网格图上进行,记第 \(r\) 行第 \(c\) 列上的格子为 \((r,c)\)。定义 \((a,b)\) 与 \((c,d)\) 之间的距离为 \(\left|a-c\right|+\left|b-d\rig ......
Codeforces Sitting 1627B 1627 Not

[Codeforces] CF1659B Bit Flipping

题面 给定一个长为 \(n\) 的 01 串,你可以进行 \(k\) 次操作。每次操作中,你可以选择任意一位,并将除了这一位以外的其它位翻转(\(1\) 变 \(0\),\(0\) 变 \(1\)),输出 \(k\) 次操作后能获得的字典序最大的字符串,并输出每一位在操作中被选择的次数。若有多解输出 ......
Codeforces Flipping 1659B 1659 Bit

[Codeforces] CF1675D Vertical Paths

CF1675D Vertical Paths 题目描述 给定一棵由 \(n\) 个顶点组成的有根树。顶点由 \(1\) 到 \(n\) 编号。任何顶点都可以是树的根。 请在树上找出这样一组路径: 每个顶点恰好属于一条路径,每条路径可以包含一个或多个顶点; 在每条路径中,每个节点的下一个节点是当前节点 ......
Codeforces Vertical 1675D Paths 1675

Codeforces Round 912 (Div. 2) E - Geo Game

考虑什么时候会改变答案的奇偶,显然可以根据\(x \oplus y\)的奇偶性分组,在组内进行跳跃不会改变,只有当组间跳跃的时候才会改变。 打表观察先手什么时候必胜,其中:\(u\)是当前获胜目标为奇/偶(1/0),\(v\)是位于哪一组,\(a,b\)代表两组还剩多少,\(st\)代表当前答案的奇 ......
Codeforces Round Game 912 Div

E. Permutation Sorting

E. Permutation Sorting You are given a permutation$^\dagger$ $a$ of size $n$. We call an index $i$ good if $a_i=i$ is satisfied. After each second, we ......
Permutation Sorting

【ErikTse】2023-Codeforces新手训练营 第六期题解

A. Wrath 题目大意 给你一个\(L\)数组和\(n\)个人,第\(i\)个人可以使用威力为\(L_i\)的闪电旋风劈击杀前面\(L_i\)人,问你最后能存活多少人? 思路 差分。开一个数组来标记当前威力的闪电旋风劈能击杀到的最远的人和使用技能的人,最远击杀的人所在的位置+1,自己的位置-1, ......
题解 训练营 Codeforces ErikTse 新手

Codeforces Round 912 (Div. 2)

Codeforces Round 912 (Div. 2) 基本概述 最难受的一集。 A 题秒了。 B 题幸苦推了两个小时,最后也通过了pretest了,结果赛后被 HACK。 C 题知道是DP,但觉得不好推状态转移方程,所以全心全意去做 B 题了。 爆掉 \(150\) 分 B. StORage ......
Codeforces Round 912 Div

CodeForces 1900D Small GCD

洛谷传送门 CF 传送门 不是很懂官方题解在干嘛。 设 \(g_x\) 为满足 \(x \mid \gcd(a_i, a_j, a_k)\) 且 \(i, j, k\) 两两不同的所有无序三元组的 \(f(a_i, a_j, a_k)\) 之和。则很容易容斥求出 \(h_x\) 为 \(x = \g ......
CodeForces 1900D Small 1900 GCD

[Codeforces] CF1603A Di-visible Confusion

CF1603A Di-visible Confusion 题目 给一个长度为 \(n\) 的序列 \(a_1,a_2,\dots,a_n\),对于每个位置 \(i\),如果 \(a_i\%\left(i+1\right)\not=0\),就可以将 \(a_i\) 删掉。删掉之后,后面的数都会往前面移 ......

[Codeforces] CF1591C Minimize Distance

CF1591C Minimize Distance 题目 一条线上有 \(n\) (\(1 \le n \le 2 \cdot 10^5\))个仓库,第 \(i\) 个仓库的位置是 \(x_i\) (\(1 \le i \le n\))。 你有 \(n\) 箱货物,要分别运到这 \(n\) 个仓库里 ......
Codeforces Minimize Distance 1591C 1591

Educational Codeforces Round 52 E

提炼 显然我们可以把每一段拆开来单独考虑 我们该段有 A^len 选择 右边肯定只要不是相同 我们的集合就+1 Alen*(Alen -1) 当然要是相同也要算1 A^len 中间当然就是随便选啥都可以 void solve() { int n,m,A;cin>>n>>m>>A; vector<in ......
Educational Codeforces Round 52

Codeforces Round 908 (Div. 2) 补题C、D

Codeforces Round 908 (Div. 2) C. Anonymous Informant 思路 可以发现,每次操作后a数组的变化: \(a_1 a_2 a_3 a_4 ... a_x ... a_n\) \(->\) \(a_1\)\(_+\)\(_x\) \(a_2\)\(_+\) ......
Codeforces Round 908 Div

Codeforces Round 883 (Div. 3)

Codeforces Round 883 (Div. 3) A. Rudolph and Cut the Rope 题意:有一颗糖果在连在绳子上,求剪短多少根绳子,他能落地 思路:只要绳子长度比钉子高度大就不用减 #include <bits/stdc++.h> using namespace st ......
Codeforces Round 883 Div

Codeforces Round 911 (Div. 2)

Codeforces Round 911 (Div. 2) 基本情况 A题秒了。 B题条件没想明白,也不造点数据就无脑交,导致罚了不少时。 B. Laura and Operations 我先推出了,对于一个数,当另外两个数的个数之和为偶数时解可行,且这个数本身要能跟后面数替换。 比如 1 1 2 ......
Codeforces Round 911 Div

Educational Codeforces Round 157 (Rated for Div. 2)

目录D. XOR Construction Educational Codeforces Round 157 (Rated for Div. 2) D. XOR Construction 方法一: 由题得 $ b_{i + 1} = a_i \oplus b_i = \cdots = b_1 \op ......
Educational Codeforces Round Rated 157

[Codeforces] CF1561C Deep Down Below

CF1561C Deep Down Below 时间限制:\(2s\) | 空间限制:\(1000MB\) 题面 题面翻译 \(T\) 组数据,每次给定 \(n\) 个任务,第 \(i\) 个任务给定 \(k_i\) 个怪物,每个怪物有一个能力值 \(a_{i,j}\) 你要按顺序把这 \(k_i\ ......
Codeforces 1561C Below 1561 Deep

Codeforces Round 910 (Div. 2)

https://codeforces.com/contest/1898 C题可以造一个大小为4的环,然后再造一个来回,这样就解决了%4=0,%4=2的情况,而奇数的情况显然无解。 #include<cstdio> #include<algorithm> #include<cstring> #incl ......
Codeforces Round 910 Div

Codeforces Round 829 (Div. 1)A1. Make Nonzero Sum (easy version)(思维找规律)

先考虑无解的情况:当n为奇数时无解 相邻的两个元素一定可以变成0 \[a[i] != a[i + 1]时, 分成[i, i], 和[i + 1, i + 1] \]\[a[i] = a[i + 1]时, 分成[i, i + 1] \]这两种情况对答案的贡献都是0,当n为奇数时我们总会有一个没办法凑成 ......
Codeforces 规律 思维 Nonzero version

Codeforces Round 731 Div3 A-G题解

Codeforces Round #731 (Div. 3) 在家打了好久COD和战雷,偶尔也得学习一下,要不然感觉时间都浪费了,游戏玩多了也腻,保持适当学习才能爽玩游戏。申请完了也不想做太难的题了,那么就来一场div3保持一下思维敏捷度吧。 A. Shortest Path with Obstac ......
题解 Codeforces Round Div3 731

Educational Codeforces Round 16 E

提炼 首先观察范围发现是1e7 好像是dp 但是发现直接朴素的dp发现是有环的 跑了一发dijk带log 答案是肯定没过 我们可以想一下 如果我要是一个10 我肯定不会从11转移过来 因为我不如先去5 再2 如果我要是一个9 我可以从8+1转移过来 也可以从52-1转移过来 这样我们就消除了环 in ......
Educational Codeforces Round 16

Educational Codeforces Round 158 (Rated for Div. 2)

A. Line Trip There is a road, which can be represented as a number line. You are located in the point \(0\) of the number line, and you want to travel ......
Educational Codeforces Round Rated 158

Codeforces Round 911 (Div. 2)补题C、D

Codeforces Round 911 (Div. 2) C. Anji's Binary Tree 思路 树形dp ac代码 #include <bits/stdc++.h> using namespace std; using i64 = long long; const i64 inf = ......
Codeforces Round 911 Div

Codeforces Round 911 (Div. 2)

B题 假设我们考虑能不能获得1,注意到b-c的奇偶性不会改变,然后特判一下只有一个大于0就行。 #include<cstdio> #include<algorithm> #include<cstring> #include<cmath> #include<map> #include<vector> ......
Codeforces Round 911 Div

CodeTON Round 7 (Div. 1 + Div. 2, Rated, Prizes!)

看到B官方题解写了一堆,而如果能注意到一些性质,几行就写完了 题意:给一个A,B构成的字符串,可以将“AB”翻转成"BA",问最多可以进行多少次翻转? 实际上在手动模拟以后发现,由于题目限制了每个位置只能翻转一次,所以情况简单了不少。 只要还没过最后一个B,那么最后一个B之前的所有A就会被反转。真正 ......
Div CodeTON Prizes Round Rated

Codeforces Round 911 (Div. 2) D

Codeforces Round 911 (Div. 2) D D. Small GCD 题意 定义\(f(a,b,c)\)为\(a,b,c\)中较小两个数的\(gcd\),给定数组\(a_{1...n}\),求\(\sum\limits_{i=1}^{n}\sum\limits_{j=i+1}^{ ......
Codeforces Round 911 Div

CodeTON Round 7 Div. 1 + 2 (CF1896)

终于把 agc 交了。 A. Jagged Swaps 模拟即可。 B. AB Flipping 显然全是 \(\texttt{B}\) 的前缀和全是 \(\texttt{A}\) 的后缀都动不了。 答案是最后一个 \(\texttt{B}\) 的位置减第一个 \(\texttt{A}\) 的位置。 ......
CodeTON Round 1896 Div CF

CodeTON Round 7 (Div. 1 + Div. 2, Rated, Prizes!)

CodeTON Round 7 (Div. 1 + Div. 2, Rated, Prizes!) A - Jagged Swaps 思路:a2到an的数只要相邻为逆序都可以交换,只需要判断a1是否为1即可 #include<bits/stdc++.h> using namespace std; # ......
Div CodeTON Prizes Round Rated