codeforces subarray maximum 1796d

CF1201C - Maximum Median

思路 二分答案。对于一个mid,查询中位数要是为mid的话至少要做多少次操作,最小操作次数就是排序后从中位数开始计算max(0, mid - v[i])的和 ac代码 #include <bits/stdc++.h> using namespace std; using i64 = long lon ......
Maximum Median 1201C 1201 CF

Hey left 1 Codeforces Round 918 (Div. 4)

题目链接 A. 3个数,其中2个数相同,输出不相同的那个 可以用if else判断,较为麻烦 用的map,输出出现一次的 #include <bits/stdc++.h> using namespace std; const int N=1e5+10; void solve(){ map<int,i ......
Codeforces Round left Hey 918

CodeForces 1312G Autocompletion

洛谷传送门 CF 传送门 考虑直接在题目给的 Trie 上 dp,设 \(f_u\) 为打出 \(u\) 结点的串的最小代价。 首先我们有 \(f_u \gets f_{fa_u} + 1\)。 我们有 \(f_u \gets \min\limits_v f_v + t + 1\),要求 \(u\) ......
Autocompletion CodeForces 1312G 1312

Educational Codeforces Round 152 (Rated for Div. 2)

layout: ../../layouts/MarkdownPostLayout.astro title: 'Educational Codeforces Round 152 (Rated for Div. 2)' pubDate: 2024-01-11 description: '一些训练' au ......
Educational Codeforces Round Rated 152

codeforces 918 div4

C 题意 : 给定一些数,问这些数的和是不是完全平方数(5*5这样) #include<cmath> #include<iostream> #define ll long long using namespace std; bool issq(ll n){ ll root = sqrt(n); re ......
codeforces div4 918 div

CodeForces 1329D Dreamoon Likes Strings

洛谷传送门 CF 传送门 考虑构造一个新串 \(t\),只保留原串 \(s_{i - 1} = s_i\) 的字符 \(s_i\)。设 \(a_i\) 为 \(t_i\) 在原串的位置。 那么新串上我们有两种操作: \(\forall i\),删除 \(t_i\)(相当于删除原串中的 \([a_i, ......
CodeForces Dreamoon Strings 1329D Likes

CodeForces 1237H Balanced Reversals

洛谷传送门 CF 传送门 容易想到把 \(s, t\) 分成长度为 \(2\) 的段考虑。容易发现 \(00, 11\) 的个数在操作过程中不会改变,所以若两串的 \(00\) 或 \(11\) 个数不相等则无解。 考虑依次对 \(i = 2, 4, \ldots, n\) 构造 \(s[1 : i ......
CodeForces Reversals Balanced 1237H 1237

vp Codeforces Round 915 (Div. 2)

vp还是比正式打舒服一些。。AB很顺畅,A题。。我只能说玩MC的都一眼秒了好吧 C题,我卡住了,结论非常好推,我直接退出来了,但是,问题是我对特例的判断不是很熟悉,或者说不是很敏感。这是一个大问题,我在wa on test 2的时候,第一反应是去看看这个算法整个有没有什么问题,事实上是没有的那么问题 ......
Codeforces Round 915 Div vp

Codeforces [Hello 2024]

Codeforces Hello 2024 主打一个昏了头 A. Wallet Exchange #include <bits/stdc++.h> #define endl '\n' //#define int long long using namespace std; const int N = ......
Codeforces Hello 2024

CodeForces 1379E Inverse Genealogy

洛谷传送门 CF 传送门 \(n\) 为偶数显然无解。 否则我们可以构造一棵 \(n\) 个点的完全二叉树,当 \(n + 1\) 是 \(2\) 的幂时满足 \(m = 1\),否则 \(m = 0\)。 当 \(n \ge 5\) 时可以递归至 \((n - 2, m - 1)\),再挂一个叶子 ......
CodeForces Genealogy Inverse 1379E 1379

CodeForces 1919F2 Wine Factory (Hard Version)

洛谷传送门 CF 传送门 题目看着感觉很像最大流,不妨建模,\(S \to i\),容量为 \(a_i\);\(i \to T\),容量为 \(b_i\);\(i \to i + 1\),容量为 \(c_i\)。答案是这个图的最大流。 考虑最大流转最小割。观察到 \(S \to i\) 和 \(i ......
CodeForces Factory Version 1919F2 1919F

CodeForces 1919E Counting Prefixes

洛谷传送门 CF 传送门 考虑一个很类似的题。我们把正数和负数分开来考虑,最后用 \(0\) 连接一些连续段,形如 \(0 - \text{正} - 0 - \text{正} - 0 - \text{负}\)。 先考虑正数。设 \(f_{i, j}\) 为考虑了 \(\ge i\) 的正数,形成了 ......
CodeForces Counting Prefixes 1919E 1919

[转帖]ORA-01450 maximum key length (3215) exceeded

https://blog.csdn.net/Hehuyi_In/article/details/106579031 一、 问题背景 给一个业务表online建索引时遇到了ORA-01450 maximum key length (3215) exceeded报错,看字面意思是字段太长了,检查表字段类 ......
exceeded maximum length 01450 3215

【题解】Codeforces 1876G Clubstep

首先考虑暴力的贪心。 从 \(r\) 到 \(l\) 依次遍历,若 \(a_i < x\) 则一直进行题目中的操作。 正确性是能保证的,因为选后面的 \(j\) 只能 \(+ 1\),而选 \(i\) 可以 \(+2\),且 \(i\) 前面的部分都是 \(+1\)。 考虑转化一下,把对 \(i\) ......
题解 Codeforces Clubstep 1876G 1876

【题解】Codeforces 1852D Miriany and Matchstick

首先考虑到第一行是固定的,先去掉第一行的贡献。 接下来会有一个 \(O(n^2)\) 的 \(\text{DP}\)。 考虑设 \(f_{i, 0 / 1, j}\) 为考虑了 \(1\sim i\) 列的放置,第 \(i\) 列填 \(\text{A / B}\) 且对数为 \(j\) 是否可行。 ......
题解 Codeforces Matchstick Miriany 1852D

Maximum Depth of Binary Tree

Source Problem Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the rootnode down to ......
Maximum Binary Depth Tree of

vp Educational Codeforces Round 160 (Rated for Div. 2)

ABC很顺畅,没有卡住然后到最后D都做不出来 D我感觉是一个类似计数dp的东西但是我找不到统计的规律但是可以得到一些性质:一个数字如果想被删掉,那它直到它左边的比它小的数字为止所有数字都要先删掉,它才能被删掉 发现自己如果不去想DP,会去往贪心的方向想,这题就是那种贪心没法完全被判断掉的因为贪心也有 ......
Educational Codeforces Round Rated 160

codeforces比赛(4):codeforces hello_2024

A、Wallet Exchange 跳转原题点击此:A题地址 1、题目大意 经典贪心:A和B玩游戏,两人依次进行以下两个操作(注意这两个操作是依次进行,而不是选择操作!!!)是:1、交换钱包或保留钱包;2、从玩家当前钱包中取出1枚硬币(注意不能为0)。 A先走,并且当某位玩家无法做出有效举动时,另一 ......
codeforces hello 2024

CodeForces Hello 2024 个人题解(A~C)

A. Wallet Exchange 时间限制: 1秒 内存限制: 256兆 输入: 标准输入 输出: 标准输出 Alice and Bob are bored, so they decide to play a game with their wallets. Alice has a coins ......
题解 CodeForces Hello 个人 2024

[Codeforces] CF1553D Backspace

CF1553D Backspace 说实话这题不配绿题 题目传送门 题面 给你两个字符串 \(S,T\) ,问你能否通过将 \(S\) 中的若干个数换成 Backspace 来使其变成 \(T\) 。Backspace 能删去前一个输入的字符。 思路 很明显,如果将一个字符换成Backspace,那 ......
Codeforces Backspace 1553D 1553 CF

[Codeforces] CF1551C Interesting Story

CF1551C Interesting Story 题目传送门 题意 给定 \(n\) 个仅由 \(\texttt{a,b,c,d,e}\) 组成的单词 (\(n \le 2\times 10^5\)),从其中选出尽可能多的单词,使得存在某个字母在这些单词中出现的次数比其他所有字母的出现次数之和还要 ......
Interesting Codeforces 1551C Story 1551

Codeforces Round 917 (Div. 2)

Codeforces Round 917 (Div. 2) 康复训练 A. Least Product #include <bits/stdc++.h> #define endl '\n' using namespace std; int n; void solve(){ cin >> n; int ......
Codeforces Round 917 Div

Codeforces Round 918 (Div. 4)

D. Unnatural Language Processing 给字符串元素按要求间隔”.“ #include<bits/stdc++.h> using namespace std; void solve(){ int n; string s; cin>>n>>s; string o=s; for ......
Codeforces Round 918 Div

Codeforces Round 917 (Div. 2)

A. Least Product 求乘积最小,可以改数组元素 #include<bits/stdc++.h> #define int long long using namespace std; void solve(){ int n; cin>>n; int ans=1; for(int i=1; ......
Codeforces Round 917 Div

Codeforces 1852D Miriany and Matchstick

首先考虑到第一行是固定的,先去掉第一行的贡献。 接下来会有一个 \(O(n^2)\) 的 \(\text{DP}\)。 考虑设 \(f_{i, 0 / 1, j}\) 为考虑了 \(1\sim i\) 列的放置,第 \(i\) 列填 \(\text{A / B}\) 且对数为 \(j\) 是否可行。 ......
Codeforces Matchstick Miriany 1852D 1852

Educational Codeforces Round 160 (Rated for Div. 2)

A 直接模拟,注意细节 #include<bits/stdc++.h> #define ll long long using namespace std; ll p[15] = {1}; void solve() { ll x; cin >> x; int len = 0; while(x / p[ ......
Educational Codeforces Round Rated 160

HydroOJ 从入门到入土(12)解决 codeforces 可以爬取但提交 Forbidden(>4.10.1)

故障内容 在使用Hydro(>4.10.1)的插件 vjudge 远程评测 codeforces 的题目的时候,会遇到题目可以正常爬,但是提交却显示Forbidden的问题。 故障分析 首先看网络。但题目可以正常爬,所以首先排除网络问题。 搜索了一下相关问题,找到一条相关信息,说 UA 可能影响在c ......
codeforces Forbidden HydroOJ 10 gt

Educational Codeforces Round 151 (Rated for Div. 2)补题A~D

Educational Codeforces Round 151 (Rated for Div. 2) A. Forbidden Integer 思路 分别处理x=1和x≠1的情况 ac代码 #include <bits/stdc++.h> using namespace std; using i6 ......
Educational Codeforces Round Rated 151

Codeforces 1909I - Short Permutation Problem

介绍一下 k 老师教我的容斥做法。 考虑固定 \(m\) 对所有 \(k\) 求答案。先考虑 \(k=n-1\) 怎么做。我们将所有元素按照 \(\min(i,m-i)\) 为第一关键字,\(-i\) 为第二关键字从小到大插入,即按照 \(n,n-1,n-2,\cdots,m+1,m,1,m-1,2 ......
Permutation Codeforces Problem 1909I Short

Codeforces 1896H2 - Cyclic Hamming (Hard Version)

非常厉害的一道计数题。从去年做到了今年。给出题人点个赞! 首先乍一看这个 \(2^k\) 的这个条件给的非常奇怪,看上去有一些奇妙的玄机。因此先尝试从这里入手找些突破口。考虑 \(a\) 和 \(b\) 中任意两个 \(1\),会有恰好一个 \(b\) 的循环移位满足这两个 \(1\) 刚好能匹配上 ......
Codeforces Hamming Version 1896H2 Cyclic
共1510篇  :1/51页 首页上一页1下一页尾页