codeforces triangle tenzing 1842e

Codeforces Round 899 (Div. 2)

Codeforces Round 899 (Div. 2) A. Increasing Sequence 解题思路: 从左往右一个个看,从1开始,如果当前位相同\(+2\),否则\(+1\)。 代码: #include <bits/stdc++.h> using namespace std; usi ......
Codeforces Round 899 Div

Educational Codeforces Round 155 D (CF1879_D)

题目大意 给一个长度为 \(n\) 的数组,求 \(\Sigma_{i=1}^{n} \Sigma_{j=i}^{n} 区间异或和 \times (j-i+1)\) 其中 \(n\leq 3e5,~a[i]\leq 1e9\) 分析 首先注意到由 \(l\) 到 \(r\) 的区间异或和可以转化为 ......
Educational Codeforces Round 1879 155

Codeforces Round 898 (Div. 4)

A. Short Sort #include<bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0), cin.tie(0); int t; cin >> t; for( string s ; t ; t -- ......
Codeforces Round 898 Div

Educational Codeforces Round 155 (Rated for Div. 2)

Educational Codeforces Round 155 (Rated for Div. 2) A. Rigged! 解题思路: 若存在\(s[i] >= s[1]\)并且\(e[i] >= e[i]\),那么答案为\(-1\). 否则,答案为\(s[1]\). 代码: #include < ......
Educational Codeforces Round Rated 155

Educational Codeforces Round 155 (Rated for Div. 2)

比赛链接 A. Rigged! 题目链接 就是一个比较简单的模拟就可以解决,如何判断能不能第一只需要考虑比他力量大的耐力是不是也比他大就行,而只要比他大,他就不可能第一,否则输出他的力量作为标杆就行,这样也可以避免比他力量小的也可以举起来。 #include<bits/stdc++.h> using ......
Educational Codeforces Round Rated 155

Codeforces463-E.Team Work-组合数、DP

Codeforces463-E.Team Work 题意:求 \[\sum_{i=1}^n \binom{n}{i} i^k \]其中\(1\leq n\leq 10^9\),\(1\leq k \leq 5000\)。 题解: 其实这个题\(k\)的数据范围就已经暗示了做法的复杂度——应该是要去考 ......
Codeforces Team Work 463

她是 Codeforces 第四名,也是知名视频平台bilibili的“网红”

在2023年9月24日~9月25日举办的Educational Codeforces Round 155 (Rated for Div. 2)上,以优秀成绩拿下第四名仅学了ACM一年的Nanani,成为最夺目的选手之一。 而且虽然是仅学了一年的选手,但她取得优异成绩后,不少网友并不感到陌生,纷纷留言 ......
Codeforces bilibili 平台 视频

Codeforces Round 895 (Div. 3) 题解集

CF1872 题解集,包含 CF1872B The Corridor or There and Back Again,CF1872C Non-coprime Split,CF1872D Plus Minus Permutation。 ......
题解 Codeforces Round 895 Div

CodeForces 715E Complete the Permutations

洛谷传送门 CF 传送门 最小交换次数等于 \(n - \text{环数}\)。所以题目要我们统计把 \(p, q\) 补全成排列,连边 \(p_i \to q_i\),环数 \(= i\) 的方案数。 考虑把边根据 \(p_i, q_i\) 的是否已知状态分成四类: \(p \to q\) \(p ......
Permutations CodeForces Complete 715E 715

CodeForces 1062F Upgrading Cities

洛谷传送门 CF 传送门 考虑一个子问题:求从某个点 \(u\) 能到达的点数。 如果要精确地计算出来,最优解法只能是 \(O(\frac{n^2}{w})\) 的 bitset。但是我们还没有利用到题目的性质,我们只需要判断一个点是否至多有一个点互不可达。 考虑拓扑排序的过程,队列里面的点两两互不 ......
CodeForces Upgrading Cities 1062F 1062

加训日记 Day1——Codeforces Round 898(div4)低级失误

开始加训的第一天 ·cf AC了两道800题,一道1000的题目有思路,但是代码必然写的不如标答优美,一道1200思路有问题; ·atcoder写了道ABC的A,B的最长回文字符串突然忘记之前怎么写的了(bushi; ·898的div4场最后一场保护,E题出大锅,中间变量没用LL溢出了,结果赛后重测 ......
Codeforces 日记 Round Day1 div4

Codeforces 1868D. Flower-like Pseudotree

题目链接:D - Flower-like Pseudotree 题目大意:给定度数数组 \({d_n}\),要求构造一个 \(n\) 个点 \(n\) 条边的连通图(也就是基环树),允许有重边,但不能有自环。需要满足第 \(i\) 个点的度数恰好为 \(d_i\),并且将环上的边全部删去后,剩下的每 ......

CodeForces 1149D Abandoning Roads

洛谷传送门 CF 传送门 考虑一条 \(1 \to i\) 的路径是否在最小生成树上。 称边权为 \(a\) 的边为轻边,边权为 \(b\) 的边为重边。 轻边若不成环则一定在最小生成树上,因此先把轻边合并,这样形成了若干连通块。 那么如果两点在一个连通块,它们只能通过轻边互达。 同时,因为是树上路 ......
CodeForces Abandoning 1149D Roads 1149

Educational Codeforces Round 97 (Rated for Div 2) G. Death DBMS

Problem - G - Codeforces 题意 给定n个字符串,每个字符串有一个值val,n次询问,每次给一个字符串,询问给定n个字符串中是询问字符串子串的值的最大值 分析 多模式匹配,从中找到给定串的子串,想到建立ac自动机,对于给定字符串,在自动机上面匹配时,沿fail指针向上跳并求最大 ......
Educational Codeforces Death Round Rated

CF1842F Tenzing and Tree 题解

Tenzing and Tree 感觉很典型的题,就是树的重心+绝对值等式 解法: 以每个点 \(i\) 为根分别 \(bfs\) ,得到一个距离数组 \(dis\) ,取前 \(k\) 个值的权值为和,更新 \(w[k]\) 的值, \(n\) 个点分别为根,更新 \(n\) 遍之后,得到 \(w ......
题解 Tenzing 1842F 1842 Tree

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\) 。 性质: 控制某个区间的最小值,需要让这个区间的数尽可能大 控制某个区间的最大值,需要让这个区间的数尽可能小 于是让排列左半的数尽 ......