codeforces sorting round 1839
[Codeforces] CF1703F Yet Another Problem About Pairs Satisfying an Inequality
时间限制 \(2s\) | 空间限制 \(250M\) 题目描述 给你一个序列$ a_1, a_2, \dots a_n $ 。请计算出满足下面条件的 $(i,j) (1 \leq i, j \leq n) $个数 。 $ a_i < i < a_j < j $ . 输入格式 第一行包含一个整数 $ ......
[Codeforces] CF1858C Yet Another Permutation Problem
Yet Another Permutation Problem - 洛谷 这题本来很简单,思路我也想到了,但是代码一直没写对,思路也一直换来换去(悲 然而发现最开始的思路是对的 题意 Alex 收到了一个名为 "GCD 排列" 的游戏作为生日礼物。这个游戏的每一轮进行如下操作: 首先,Alex 选择 ......
[Codeforces] CF1506C Epic Transformation
Epic Transformation - 洛谷 算是今天的题目里边思维难度最高的一道了,但是代码真的简单的要死 题意 你有一个长度为 \(n\) 的序列 \(a\),你可以对其进行下列操作: 选择 \(i,j\) 满足 \(*a_i\neq a_j*\) 然后删除 \(*a_i,a_j*\) 两个 ......
[Codeforces] CF1719C Fighting Tournament
题目传送门 另:多测不清空,WA两行泪 题意 Burenka正准备去观看一年中最有趣的体育活动 —— 她朋友Tonya组织的格斗锦标赛。 有 n 名运动员参加了大赛,标号分别为为 1,2,... ,n 。第 i 名运动员的实力是 \(a_i(1 \le a_i \le n)\) 。每个运动员的实力是 ......
[Codeforces] CF1728C Digital Logarithm
题目传送门 很奇妙的一道题,我想到了正解,但是又没有完全想到 题意 我们定义 \(f(x)\) 表示取出 \(x\) 在十进制下的位数。( 如 \(f(114514) = 6, \; f(998244353) = 9\) )。形式化讲,就是 \(f(x) = \lfloor \log_{10} x ......
[Codeforces] CF1766D Lucky Chains
有某位特别爱RE的同学问的老师,由此引发了一场血案 主打的就是一坚持不懈(悲 题意 给出两个正整数 \((x,y)\),满足 \((x,y),(x+1,y+1),(x+2,y+2),\dots,(x+k,y+k)\) 都是互质的,直到 \((x+k+1,y+k+1)\) 起不互质 问 \(k\) 的 ......
[Codeforces] CF1857D Strong Vertices
Strong Vertices - 洛谷 题解是个好东西 题意 给定两个数组 \(a\) 和 \(b\),对此构造一张有向图: 若 \(a_u−a_v≥b_u−b_v\),则 \(u\) 向 \(v\) 连边。 求所有向其他所有顶点连边的顶点个数,并按从小到大顺序输出它们。 思路 先对原式进行转换: ......
[Codeforces] CF1714E Add Modulo 10
题目传送门 代码一遍AC真的很爽,样例都是一遍过 题意 每个测试点含多组测试数据。 对于每组测试数据 第1行 一个整数 \(n\) ,表示该数据个数 第2行 \(n\) 个整数,你需要判断是否符合题意的数据 对每组数据,你可以对其作若干次(可以为零)如下操作: 选取数据中的一个数 \(a_i\) 将 ......
[Codeforces] CF1475C Ball in Berland
Ball in Berland - 洛谷 题意 在毕业典礼上,有\(a\)个男孩和\(b\)个女孩准备跳舞,不是所有的男孩和女孩都准备结伴跳舞。 现在你知道\(k\)个可能的舞伴,你需要选择其中的两对,以便使没有人重复地出现在舞伴里,求可能的数量。 思路 暴力 最朴素,也是简单的方法,就是通过暴力组 ......
[Codeforces] CF1705C Mark and His Unfinished Essay
题目传送门 题意 给定长度为 \(n\) 的字符串 \(s\),进行 \(c\) 次操作,每次操作将 \(s_l\) 到 \(s_r\) 复制到字符串尾。 全部操作结束后有 \(q\) 次询问,每次询问字符串 \(s\) 的第 \(k\) 位。 数据保证 \(r\) 不超过当前字符串长度,\(k\) ......
Codeforces Round 903 (Div. 3)
Codeforces Round 903 (Div. 3) A. Don't Try to Count 大概题意给你两个字符串a,b。a串可进行的操作为将整个a串复制到之前的a串后面(直接用a+a即可),然后看操作多少次可以让b串变为a串的子串如果不能就输出-1。 #include <iostrea ......
Codeforces Round 905 (Div. 3)
Codeforces Round 905 (Div. 3) A. Morning 题意:操作:显示,向前走都为一次操作;目标:显示这四个数 思路:0->10,然后依次作差就行 #include <bits/stdc++.h> using namespace std; void solve(){ ch ......
Codeforces Round 910 (Div. 2)
Codeforces Round 910 (Div. 2) A. Milica and String 解题思路: 统计给定字符串\(s\)中的\(B\)的数量,记录为\(cnt\)。 如果\(cnt == k\):输出0; 如果\(cnt < k\):从左往右数,将第\(cnt - k\)个\(A\ ......
Codeforces Round 909 (Div3)(本菜鸟只补到了E)
Codeforces Round 909 (Div.3) A. Game with Integers 水题,就是可以被3整除的输出“Second”,不能被3整除的输出“First” #include<iostream> using namespace std; int main() { int t; ......
Codeforces Round 910 (Div. 2)
Preface 这场其实挺早之前就写完代码了,但一直没时间写博客(玩云顶新赛季玩的) 感觉F其实不难但为什么就是想不出来呢,感觉后面的题就是很难突破的说 A. Milica and String 分类讨论+枚举即可 #include<cstdio> #include<iostream> #inclu ......
golang sort包应用
一、sort内置排序函数 函数 作用 func Float64s(x []float64) 对float64类型的切片进行升序排序 func Float64sAreSorted(x []float64) bool 判断float64类型切片x是否按升序排序 func Ints(x []int) 对i ......
P5143 攀爬者(结构体+sort排序)
P5143 攀爬者 sort排序: 对于数组而言 sort(数组+begin,数组+stop)(左闭右开) 例: sort(a+1,a+n+1)=sort(a[1]~a[n]) 对于结构体 在数组基础上多一个cmp 运用:sort(数组+begin,数组+stop,cmp) cmp本身需要定义一个函 ......
CodeForces 1898F Vova Escapes the Matrix
洛谷传送门 CF 传送门 Type \(1\) 是简单的。直接输出空格个数即可。 Type \(2\) 也是简单的。显然要堵住不在起点和出口最短路上的格子,答案为空格个数减去起点到任一出口的最短路。 考虑 Type \(3\)。容易发现答案为空格个数减去起点到任两个出口的最短路(公共部分只算一次)。 ......
Codeforces Round 697 (Div. 3)
A. Odd Divisor #include<bits/stdc++.h> using namespace std; #define int long long //#define int __int128 #define double long double typedef pair<int,i ......
[Codeforces] CF1475C Ball in Berland 题解
Ball in Berland - 洛谷 题意 在毕业典礼上,有个男孩和个女孩准备跳舞,不是所有的男孩和女孩都准备结伴跳舞。 现在你知道个可能的舞伴,你需要选择其中的两对,以便使没有人重复地出现在舞伴里,求可能的数量。 思路 暴力 最朴素,也是简单的方法,就是通过暴力组合进行配对。 #incl ......
Codeforces Round 905 (Div. 2)
\(A. Chemistry\) https://codeforces.com/contest/1888/submission/233505834 \(B. Raspberries\) https://codeforces.com/contest/1888/submission/233506474 ......
Codeforces Round 910 E
tilian 我们发现可以通过交换相邻两个的方式让字典序小的任意移动 我们目标串t 要是t[0]为 c 我们肯定是找到第一个合法的c的位置 每次去找合法并且最优的 那么哪些是不合法的呢 比如我 比c小的 a,b 位置还在第一个c前肯定就不能用了 我们用26个set维护这个过程即可 void solv ......
Codeforces Round 909 (Div. 3)
Codeforces Round 909 (Div. 3) A. Game with Integers 题意: 给定一个数\(x\),\(A,B\)两人轮流进行操作,\(A\)先操作。每次给\(x\)加一或者减一,操作完后\(x \% 3 == 0\)者获胜。判断获胜者。 解题思路: 判断\(A\) ......
codeforces 50题精选训练
本章节参考:2020,2021 年 CF 简单题精选 - 题单 - 洛谷 | 计算机科学教育新生态 (luogu.com.cn) 首先,很容易观察到点的一些特征: - 都在第一象限;- 点的分布越来越稀疏。 以样例为例: 还有无限个点没有画出来。 根据点的分布越来越稀疏的特性,能不能发现收集点的规律 ......
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 ......
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 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\) ......
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 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 合集第三弹
这个合集主要是近期的 CodeForces 比赛题。 1898. Codeforces Round 910 (Div. 2) https://codeforces.com/contest/1898 A. Milica and String 很容易发现答案不超过 \(1\),然后分类讨论当前 B 的个 ......