codeforces 280c game tree

回顾经典之neko_tree

一.neko_tree 猫neko树是一种维护序列的数据结构。在处理绝大多数线段树能处理的问题(如最大子段和,区间最大值,区间\(gcd\)等满足结合律且能快速合并的信息)上能做到\(O(nlogn)\)预处理后\(O(1)\)的询问。但是不支持修改。 neko树怎么维护信息?想象在线段树上取得区间 ......
neko_tree 经典 neko tree

CF1867F Most Different Tree记录

题目链接:https://codeforces.com/contest/1867/problem/F 题意简述 记 \(P(T)\) 为一棵树 \(T\) 的所有子树的集合。给定一棵 \(n\) 个点的树 \(T\),找出点数相同的树 \(T'\),使 \(P(T')\) 的“与 \(P(T)\) ......
Different 1867F 1867 Most Tree

Educational Codeforces Round 132 (Rated for Div. 2)

基本情况 AB秒了。C跨度有点太大,题解暂时都还没理解。 C. Recover an RBS Problem - C - Codeforces 待补题 ......
Educational Codeforces Round Rated 132

Codeforces Round 834 (Div. 3)

Codeforces Round 834 (Div. 3) A. Yes-Yes? 题意:就是Y后面跟e,e后面跟s,s后面跟Y #include <iostream> using namespace std; void solve() { string x; cin >> x; int l = x ......
Codeforces Round 834 Div

Codeforces Round 839 (Div. 3)

Codeforces Round 839 (Div. 3) A. A+B? 跳过太水了、、、、、 #include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int a,b; sc ......
Codeforces Round 839 Div

【模板】树上启发式合并 dsu on tree

所选例题 模板 点击查看代码 #include<bits/stdc++.h> using namespace std; #define endl '\n' #define pb push_back #define rep(i,a,n) for(int i=a;i<=n;i++) #define pe ......
模板 tree dsu on

Educational Codeforces Round 131 (Rated for Div. 2)

基本情况 AB秒了。C知道是二分答案,check死活写不出来。 C. Schedule Management Problem - C - Codeforces 错误分析 这题比较绕,搞了一个对应关系,大脑转不过来。 写check的时候完全想不出合理的思路。 很明显的要用桶来计数,但是怎么用不知道了。 ......
Educational Codeforces Round Rated 131

Educational Codeforces Round 159 (Rated for Div. 2)

Educational Codeforces Round 159 (Rated for Div. 2) A - Binary Imbalance 解题思路: 有一对\((0,1)\),那么\(0\)就能无限增长。 代码: #include <bits/stdc++.h> using namespac ......
Educational Codeforces Round Rated 159

题解 ABC333F【Bomb Game 2】

来个可能有点麻烦但不用动脑子的暴力做法。 直接设 \(f_{i,j}\) 表示有 \(i\) 个人时,第 \(j\) 个人幸存的概率。 显然有 \(f_{1,1}=1\)。 对于 \(i > 1\),分类讨论容易得到: \[f_{i,j}= \begin{cases} \frac{f_{i,n}}{ ......
题解 333F Bomb Game ABC

Codeforces Round 915 (Div. 2)

基本情况 A题还没进入状态,卡了快10分钟。 B题一开始想复杂了,以为是树的直径,后面推出来发现针对叶子数目讨论就行了,正确思路出来太慢了(一个半小时)。 C题留了半个多小时,随便口胡了一个LIS思路,但是判断无解没思路。 C. Largest Subsequence Problem - C - C ......
Codeforces Round 915 Div

Educational Codeforces Round 134 (Rated for Div. 2)

基本情况 AB秒了。 C搞了一个错的二分答案,虽然过样例了。 C. Min-Max Array Transformation 错误分析 没有进一步推导性质,而是觉得数据单调递增估计是二分,然后就无脑写,实际上 check 的正确性没有保证。 bool check(int ind, int now) ......
Educational Codeforces Round Rated 134

CF1906K Deck-Building Game记录

CF1906K Deck-Building Game 题目链接:https://codeforces.com/problemset/problem/1906/K 题意 有大小为 $n$ 的多重集 $A$。求找到两个不相交子集,使它们各自的异或和相等的方案数。 很容易将其转换为求如下值: $$ \su ......
Deck-Building Building 1906K 1906 Deck

Codeforces Round 817 (Div. 4)

基本情况 ABCD秒了。 E一眼二位前缀和,但是板子就是不熟,硬生生拖了半小时。 E. Counting Rectangles Problem - E - Codeforces 真没啥好说的 二位前缀和就是不熟练、不透彻。 挂篇博客复习 ......
Codeforces Round 817 Div

Codeforces Round 855 (Div. 3)

Codeforces Round 855 (Div. 3) A. Is It a Cat? 题意:要求: 字符串必须以只包含字母 "m "或 "M "的非空序列开始 必须紧跟由'e'或'E'字符组成的非空序列 必须紧接着仅由字符'o'或'O'组成的非空序列 必须紧接着是仅由字符'w'或'W'组成的非 ......
Codeforces Round 855 Div

Codeforces Round 863 (Div. 3)

Codeforces Round 863 (Div. 3) A. Insert Digit 题意:插入一个字母使得这个数字最大化 思路:只要从前往后便利就行 #include <iostream> using namespace std; void solve() { int n, k; cin > ......
Codeforces Round 863 Div

Codeforces Round 913 (Div. 3)

Codeforces Round 913 (Div. 3) A:ABC A. Rook 简单题,就两个循环搞定(直接上码) #include <bits/stdc++.h> using namespace std; void solve() { char a; int b; cin >> a >> ......
Codeforces Round 913 Div

Codeforces Round 867 (Div. 3)

Codeforces Round 867 (Div. 3) A:ABCD (E差一点点,最后把那种特殊情况想出来然后没写上去就结束了) A. TubeTube Feed 题意:给两个数组分别是时间和价值,要价值最大但是只能选一个 思路:最开始以为是01背包,结果只选一个,一个一个枚举就行 #incl ......
Codeforces Round 867 Div

Codeforces Round 913 (Div. 3)

CF1907总结 A.Rook 题面翻译 给出车在国际象棋棋盘中的位置,输出其可到达的坐标(不必在意顺序)。 车可以横着或竖着走任意格数。 分析 题意明了,输出车所在行和列所有格子的序号(除车所在位置外)。 code #include <bits/stdc++.h> using namespace ......
Codeforces Round 913 Div

Codeforces Round 891 (Div3)

Codeforces Round 891 (Div. 3) A. Array Coloring 这个我vp的时候写复杂了,想不到答案的思路这么清晰,将两部分分别看,将偶数加进去其奇偶性不变,只有奇数加进去才会改变奇偶性,so只有改变偶数次奇偶性才能使其奇偶性相同,所以cnt%2==0. #inclu ......
Codeforces Round Div3 891 Div

Codeforces Round 816 (Div. 2) VP

基本情況 A秒了,B错一次之后也过了,C没思路。 B. Beautiful Array Problem - B - Codeforces void solve() { long long n, k, b, s; memset(ans, 0, sizeof(ans)); std::cin >> n > ......
Codeforces Round 816 Div VP

Codeforces Round 815 (Div. 2)

基本情况 脑子太不清楚了。 A题有思路,但是各种细节问题(数论题太不熟练了),错了好几次才过。 B题直接分析数据愣猜一个解,猜对了。 A. Burenka Plays with Fractions Problem - A - Codeforces 难点在分析输出 \(1\) 的情况。 我的想法是通分 ......
Codeforces Round 815 Div

Codeforces Round 915 (Div. 2)

A. Constructive Problems 看了一眼数据,猜测可能是n,m里的最大 #include<bits/stdc++.h> using namespace std; void solve(){ int a,b; cin>>a>>b; int ans=max(a,b); cout<<an ......
Codeforces Round 915 Div

Codeforces Round 915 (Div. 2)

Codeforces Round 915 (Div. 2) 唉,菜狗。 A - Cover in Water int main() { IOS; for (cin >> _; _; --_) { cin >> n >> m; cout << max(n, m) << '\n'; } return 0 ......
Codeforces Round 915 Div

[LeetCode] 2415. Reverse Odd Levels of Binary Tree

Given the root of a perfect binary tree, reverse the node values at each odd level of the tree. For example, suppose the node values at level 3 are [2 ......
LeetCode Reverse Binary Levels 2415

Codeforces Round 915 (Div

Codeforces Round 915 (Div. 2) 题解 A.Constructive Problems 直接找规律,或者手玩一下发现按照对角线斜着放最优(不会证),答案即为 \(max(n, m)\) 。 B.Begginer's Zelda 每次我们选择的端点一定是叶子结点,最优性是显然 ......
Codeforces Round 915 Div

Codeforces Round 910 (Div. 2) D. Absolute Beauty(数论)

Codeforces Round 910 (Div. 2) D. Absolute Beauty 思路: 将每个 \(a_i\) 与 \(b_i\) 转化为线段,大数在后,小数在前 即 L ( min) —— R (max) 对于 \(b_i\) 和 \(b_j\) 的 交换 : ​ L1 —— R ......
数论 Codeforces Absolute Beauty Round

Codeforces Round 910 (Div. 2) B. Milena and Admirer(数论)

Codeforces Round 910 (Div. 2) B. Milena and Admirer 思路: 要使数组非递减,则可以先进行倒序遍历,对于当前的 \(a_i\) , 要使 \(a_i\le a_{i+1}\) 我们可以进行贪心,让 \(a_i\) 分完尽可能使每个 \(a_i / k ......
数论 Codeforces Admirer Milena Round

Educational Codeforces Round 139 (Rated for Div. 2) D. Lucky Chains(数论)

Educational Codeforces Round 139 (Rated for Div. 2) D. Lucky Chains 思路: 假设幸运为k , 则 gcd(x+k,y+k) ≠ 1 , k取最小整数(k>=0) 由此可设 因子为 d , (x+k)%d = 0 , (y+k)%d ......
数论 Educational Codeforces Chains Round

Codeforces Round 891 (Div. 3) F. Sum and Product (数论)

Codeforces Round 891 (Div. 3) F. Sum and Product 思路: 对于x,y:ai+aj=x —> aj=x-ai 因此 ai*(x-ai) = y ——> ai = (x 土 sqr( x^2 - 4y ) ) /2 对应的 ai 就是要的两个值 若两个值不 ......
数论 Codeforces Product Round 891

Educational Codeforces Round 159 (Rated for Div. 2) C. Insert and Equalize (贪心+数论)

Educational Codeforces Round 159 (Rated for Div. 2) C. Insert and Equalize 思路: 首先对 \(a\) 进行排序, 然后对所有差值取gcd ,获得可用的最大因子 \(gc\), 答案有两种情况: 一种是 \(a_{n+1}\) ......
共2080篇  :6/70页 首页上一页6下一页尾页