codeforc

Codeforces Round 898 (Div. 4)(A-H)

Codeforces Round 898 (Div. 4) A.给abc的某个排列,问能否最多交换一次让排列变成abc 直接看有几个不在原位就行 查看代码 #include<iostream> using namespace std; void solve() { char a,b,c; cin>> ......
Codeforces Round 898 A-H Div

# [Codeforces Round 898 (Div. 4)] E. Building an Aquarium

Codeforces Round 898 (Div. 4) E. Building an Aquarium You love fish, that's why you have decided to build an aquarium. You have a piece of coral made ......
Codeforces Building Aquarium Round 898

Codeforces Round 898 (Div. 4)

Codeforces Round 898 (Div. 4) A Short Sort 直接枚举许所有情况即可 /* * * Author: north_h * Time: 2023-09-21 22:35:49 * * Problem: A. Short Sort * Contest: Codefo ......
Codeforces Round 898 Div

Codeforces Round 898 (Div. 4)

Codeforces Round 898 (Div. 4) A. Short Sort 解题思路: 遍历所有交换情况,看是否有\(abc\). 代码: #include <bits/stdc++.h> using namespace std; using ll = long long; const ......
Codeforces Round 898 Div

Educational Codeforces Round 123 - D(思维题)

目录D. Cross Coloring D. Cross Coloring 题意 $n \times m $ 的方格纸上进行 q 次操作,每次操作选择某整行 x 和某整列 y,使得行 x 和列 y 均涂上 k 种颜色中的一种。问你最终的方案数 思路 代码 //>>>Qiansui #include< ......
Educational Codeforces 思维 Round 123

Educational Codeforces Round 154 (Rated for Div. 2) A-D

传送门:edu154/div2 A. Prime Deletion 题意:给定一个0-9的排列,要求一个长度>=2的子序列,使得该子序列是质数 做法:考虑31或者13即可。不过当时没有立刻想到,感觉1000以内的质数必有答案,打了暴力。用时就多了点。 Code #include<bits/stdc+ ......
Educational Codeforces Round Rated 154

CodeForces 1730F Almost Sorted

洛谷传送门 CF 传送门 过程相当于是将 \(p\) 重排列。设 \(b_i\) 为 \(p\) 中数为 \(i\) 的位置。考虑当前填的数 \(x\) 贡献的逆序对数,相当于是当前所有已经填入 \(p\) 的数 \(y\),都有 \([b_y > b_x]\) 的贡献。 考虑 \(p_{q_i} ......
CodeForces Almost Sorted 1730F 1730

Codeforces Round 753 (Div. 3) B. Odd Grasshopper

一维坐标轴上,蚱蜢一开始在 \(x_0\) 。在第 \(1\) 秒往后的每秒,第 \(i\) 秒蚱蜢可以跳 \(i\) 步。即若当时在 \(x\) ,可以跳到 \(x + i\) 或 \(x - i\) 。额外的,若 \(x\) 为偶数,蚱蜢会往左跳;否则会往右跳。 询问 \(n\) 秒后蚱蜢的坐标 ......
Grasshopper Codeforces Round 753 Div

CodeForces 889E Mod Mod Mod

洛谷传送门 CF 传送门 发现如果取模中途没有出现 \(0\),则可以 \(x \gets x + 1\)。 由此设 \(f_{i, j}\) 为考虑 \([1, i]\),最后取模得到的范围是 \([0, j]\)。 设最后的结果为 \(x\),中间结果减去 \(x\) 和为 \(y\),那么对答 ......
Mod CodeForces 889E 889

Educational Codeforces Round 143

A. Two Towers #include <bits/stdc++.h> using namespace std; #define int long long #define mp make_pair using pii = pair<int, int>; using vi = vector<i ......
Educational Codeforces Round 143

Educational Codeforces Round 107

依然是四题,但是感觉太久没打,好像变得迟钝了。 B题大概就是令 \[c={10}^k, a=c*3^k, b=c*2^k \]C的话直接暴力维护每种颜色的第一个位置就行,反正只有50个 D的话刚开始没什么想法,构造题什么的真的不会啊 打表之后发现,对于k,在cost为0的情况下,最多能造出长度为\( ......
Educational Codeforces Round 107

Codeforces Round 897 (Div. 2) A-E

A. green_gold_dog, array and permutation 题意:给出一个长为\(n\)的数组\(a\),找到一个长为\(n\)的排列\(b\),使得\(a\)与\(b\)对应位置上的元素的差尽可能大 Solution 将数组\(a\)排序,然后令排列\(n,n-1,...,2 ......
Codeforces Round 897 A-E Div

CodeForces 1863G Swaps

洛谷传送门 CF 传送门 看到 \(a_{a_i}\) 和 \(a_i \in [1, n]\),果断连边 \(i \to a_i\),得到内向基环森林。 那么每次相当于把 \(a_i\) 变成自环,连边 \(i \to a_{a_i}\)。 但是每次操作都改变图的形态很不好办,考虑打标记。 每次 ......
CodeForces 1863G Swaps 1863

Codeforces Global Round 17 A. Anti Light's Cell Guessing

给一个 \(n \times m\) 的网格,里面藏了一个炸弹 \((x_0, y_0)\) 。你可以选择 \(k\) 个坐标 \((x_1, y_1), (x_2, y_2), \cdots, (x_k, y_k)\) 。第 \(i\) 次选择计算机会回复你一个数 \(d_i = |x_0 - x ......
Codeforces Guessing Global Round Light

Educational Codeforces Round 117 (Rated for Div. 2) B. Special Permutation

给三个正整数数 \(n, a, b\) ,\(n\) 是偶数。写出 \(n\) 的任意一个排列满足左边一半的最小值等于 \(b\) 且右边一半的最大值等于 \(a\) 。 性质: 控制某个区间的最小值,需要让这个区间的数尽可能大 控制某个区间的最大值,需要让这个区间的数尽可能小 于是让排列左半的数尽 ......

Educational Codeforces Round 118 (Rated for Div. 2) A. Long Comparison

白板上左右写上两个数,每个字的形式表示为:一个正整数 \(x\) 和 \(p\) 个末尾 \(0\) 。 询问左右两个数的大小关系。 假设左边为 \(x_1, p_1\) ,右边为 \(x_2, p_2\) 。 先看数位长度 若 \(dig_{x_1} + p_1 < dig_{x_2} + p_2 ......

Codeforces Round 761 (Div. 2) B. GCD Problem

给一个正整数 \(n\) 。找到三个不同的正整数 \(a, b, c\) 满足 \(a + b + c = n\) 并且 \(gcd(a, b) = c\) 。 公式归一化简: \[\begin{cases} a + b + c = n, \\ gcd(a, b) = c \end{cases} \ ......
Codeforces Problem Round 761 Div

Codeforces Round 764 (Div. 3) B. Make AP

有三个正整数 \(a, b, c\) 。需要执行以下操作严格一次: 选择任意一个正整数 \(m\) 并让严格一个 \(a, b, c\) 之一乘以 \(m\) 。但不能改变他们的顺序。 回答是否可以经过一次操作后使 \(a, b, c\) 变为等差。 分类讨论题: 三种情况满足一种即可。(已知 \( ......
Codeforces Round Make 764 Div

Codeforces Round 773 (Div. 2) B. Power Walking

有 \(n\) 个增幅道具,第 \(i\) 个道具种类为 \(a_i\) ,一个人的强度 \(w\) 为他所有道具的种类数。对于 \(k ] \in[1, n]\) ,询问将 \(n\) 个道具分配给 \(k\) 个人且每个人至少分配到一个道具后,能够得到的最想强度和 \(\sum_{i=1}^{n ......
Codeforces Walking Round Power 773

Educational Codeforces Round 100

B. Find The Array 对于条件二来说,1 是万金油的存在,所以我们只需要把奇数位置或偶数位置全部变成 1 即可。因为要求差值小于\(\frac s 2\),所以我可以求出奇偶位的和修改较小值即可。 #include <bits/stdc++.h> using namespace std ......
Educational Codeforces Round 100

Educational Codeforces Round 101

C. Building a Fence 首先相邻的两个栅栏是否相交的判断可以转换为两个栅栏的底的距离差,这样实际上我们并不需要维护出栅栏,只需要维护底的位置即可。 假设上一个栅栏可摆放的位置是\([x,y]\),则与之相交的栅栏应该摆放在\([x-k+1,y+k-1]\)。如果当前地面高度是\(h\ ......
Educational Codeforces Round 101

Educational Codeforces Round 102

C. No More Inversions 首先我们先来看对 1 2 3 ... k-1 k k-1 ... 3 2 1 这样的序列进行题目中的变化操作。 k = 2 1 2 1 逆序对1个 2 1 2 逆序对1个 k = 3 1 2 3 2 1 逆序对4个:(2,1) (3,2) (3,1) (2 ......
Educational Codeforces Round 102

Educational Codeforces Round 150

A. Game with Board 当\(n>4\)时,Alice 可以把序列变成n-2,1,1,Bob只能操作成n-2,2,此时 Alice获胜。 #include <bits/stdc++.h> using namespace std; #define int long long using ......
Educational Codeforces Round 150

codeforces图论合集

Cyclic Operations 给定一个数组$a$,每次构造一个数组$\space l \space$长度为$\space k\space$,数组$\space a\space$与$\space l\space$转换关系如下 : $a_{l_1}\to l_2\space,\space a_{l ......
codeforces

Codeforces Round 897 (Div. 2) 考试总结

这次打得很好,相较于 div3 的脑残题和签到题来说,div2 的思维难度更加的大。同时还有除传统题外,其他的题型出现。比如交互题等。这次能在考场上想出三道较于之前是有很大的进步的。 赛时实况: A B C D E1 E2 F √ √ √ × × × × 赛后改题情况: A B C D E1 E2 ......
Codeforces Round 897 Div

Codeforces Round 882 (Div. 2) 题解

Codeforces Round 882 (Div. 2) 这题很简单的吧,比较脑抽的就是D,下面详细说,我nloglogn过不去2e5说实话有点不应该,感觉有更聪明的办法搞这个。 很奇怪的一点是,yongwham究竟是怎么只做出来A的???? A. The Man who became a God ......
题解 Codeforces Round 882 Div

Codeforces 1868C/1869E Travel Plan 题解 | 巧妙思路与 dp

题目链接:Travel Plan 题目大意:\(n\) 个点的完全二叉树,每个点可以分配 \(1 \sim m\) 的点权,定义路径价值为路径中最大的点权,求所有路径的价值和。 对于任意长度(这里主要指包括几个节点)的路径 \(t\),最大点权不超过 \(k\) 的方案数有 \(k^t\) 个, 因 ......
题解 Codeforces 思路 Travel 1868

Codeforces Round 772 (Div. 2) E.Cars 二分图染色/拓扑排序

Cars 二分图染色/拓扑排序 题意 坐标轴 $X$ 上有 $n$ 辆汽车。每辆车最初位于一个整数点,并且没有两辆车位于同一点。此外,每辆车都可以向左或向右定向地、可以随时以任何恒定的正速度地沿该方向移动。定义两种关系: 如果两辆汽车无论速度如何都永远不会到达同一点,我们称它们为 无关紧要的。换句话 ......
拓扑 Codeforces Round Cars 772

Codeforces Round 776 (Div. 3) B. DIV + MOD

定义函数 \(f_a(x) = \lfloor \frac{x}{a} \rfloor + x \mod a\) 。 回答 \(q\) 个独立询问,每个询问给出 \(l, r, a(1 \leq l,r,a \leq 10^9)\) ,询问 \(f_a(x)\) 在定义域 \([l,r]\) 上的最 ......
Codeforces Round 776 Div DIV

Codeforces Round 781 (Div. 2) B. Array Cloning Technique

给一个长度为 \(n\) 的数组 \(a\) 。开始只有一份所给 \(a\) 的副本。你可以做以下两种操作: 选择任意一个副本并且克隆它,然后将会多出一个克隆副本。 交换两个元素,他们属于任意两个副本(可能是同一个)。 需要判断最小操作数,使有一个副本的所有元素相同。 观察一:只需要在开始的副本上让 ......
Codeforces Technique Cloning Array Round