codeforces different arrays 1783d

Codeforces Round 742 Div2 A-D题解

Codeforces Round 742 Div2 A-D题解 A. Domino Disaster 这题就是说给出一些2x1 tile,然后给出2xn的第一行构造,问第二行 这个刚开始想着是啥dp,一看那么多人过了果断改思路,发现这题就是个模拟题,就是把U换成D,D换成U,L和R不影响,然后输出就 ......
题解 Codeforces Round Div2 742

Codeforces Round 899 (Div. 2)

Preface 好久没现场打CF了(玩CC玩的.jpg),但这场久违的打的还不错,把Kusanagi_Misuzu这个小号也打上橙了 虽然开场的时候状态不佳写的巨慢,但后面还是靠着ztc带我做出E1成功题数反超上大分 接下来要考虑启动第三个小号了,只敢打Div2的FW是这样的 A. Increasi ......
Codeforces Round 899 Div

Codeforces Round 738 (Div. 2) A. Mocha and Math

给一个数组 \(a_1, a_2, \cdots, a_n\) 。可以执行以下操作任意次: 选择 \(l, r (1 \leq l < r \leq n)\) ,对于任意 \(l \leq i \leq r\) ,同时执行所有 \(a_{l + i} = a_{l + i} \& a_{r - i} ......
Codeforces Round Mocha Math 738

Codeforces Round 899 (Div. 2) 记录

Codeforces Round 899 (Div. 2) A. Increasing Sequence 点击查看代码 #include<bits/stdc++.h> using namespace std; const int maxn=105; int t,n; //map<int,bool> ......
Codeforces Round 899 Div

Codeforces Round 898 (Div. 4)

这是我的vp,不是正真的contest. A: 不想多说,读者应该可以做到的!!! B: 让g=product(移除掉0的a): 如果有多过1个0答案肯定是0。 如果只是有1个0答案就是g。 没有0,答案就是max(g/a[i]*(a[i]+1)) 任何 i。 C: 没有仔细想那个profit的fo ......
Codeforces Round 898 Div

Codeforces Round 899 (Div. 2)

赛后四题 B题直接枚举不存在的元素即可 C题的trick有点像之前abc的某道题,对于奇数位置它一定可以贡献,对于偶数位置,如果它有数选了,那么它就能够贡献。 \(f[i]\)表示到前i个且至少选了一个的最大答案。 #include<cstdio> #include<algorithm> #incl ......
Codeforces Round 899 Div

Codeforces Round 738 (Div. 2) B. Mocha and Red and Blue

给一个字符串,包含字符 \(B\) , \(R\) ,\(?\) 。其中 \(?\) 可能为 \(B\) 或 \(R\) 。 规定不完美数为字符串中相同字符连续出现的次数,询问一个字符串的最少可能不完美数。 观察到 \(BR\) 或 \(RB\) 需要尽可能多,于是考虑尽可能让相邻字符不同。 容易证 ......
Codeforces and Round Mocha Blue

Technocup 2022 - Elimination Round 2 Two Arrays

给定两个数组 \(a_1, a_2, \cdots, a_n\) 和 \(b_1, b_2, \cdots, b_n\) 。 定义 \(a\) 的一次操作: 选择任意一个非负整数 \(k(0 \leq k \leq n)\) 。 选择任意 \(k\) 个独立的下标 \(i_1 \leq i_2 \l ......
Elimination Technocup Arrays Round 2022

Technocup 2022 - Elimination Round 3 B. Array Eversion

给一个长度为 \(n\) 的数组。执行一次以下操作: 让 \(x = a_n\) ,然后数组 \(a\) 被分为左右两部分。左部分包含所有 \(\leq x\) 的元素,右部分包含所有 \(> x\) 的元素。且数组整体的原顺序不变。 询问经过多少次操作后,数组不再改变? \(1 \leq n \l ......
Elimination Technocup Eversion Array Round

Codeforces Round 750 (Div. 2) B. Luntik and Subsequences

给一个数组 \(a_1, a_2, \cdots, a_n\) ,定义 \(s = \sum_{i = 1}^{n} a_i\) 。 询问有多少个 \(a\) 的子序列满足 \(\sum a_{i_k} = s - 1\) 。 显然要选出一个 \(1\) 不加入子序列,任意一个 \(0\) 可以加入 ......
Subsequences Codeforces Luntik Round 750

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

IDEA Redundant array length check 警告

在 Java 中判断数组为空通常会同时判断 null 和长度 if (array == null || array.length == 0) { return; } 但是如果在判断段长度是否为 0 后,再进行遍历的操作,就会提示 Redundant array length check,例如下面的代 ......
Redundant length array check IDEA

加训日记 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

7.常用API(Arrays,Lambda表达式)

常用API(Arrays,Lambda表达式) Arrays类 概念: 数组类 常用方法: public static String toString(数组) 把数组拼接成一个字符串 public static int binarySearch (数组,查找的元素) 二分查找法查找元素 public ......
表达式 常用 Arrays Lambda API

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