Educational

Educational Codeforces Round 158 (Rated for Div. 2)

Educational Codeforces Round 158 (Rated for Div. 2) A - Line Trip 解题思路: 每次到加油站油都会加满,所以我们考虑到达两个加油站间需要的最大油量即可。 注意:最后一站的油量是一个来回。 代码: #include <bits/stdc+ ......
Educational Codeforces Round Rated 158

Educational Codeforces Round 158 (Rated for Div. 2)

Educational Codeforces Round 158 (Rated for Div. 2) 基本情况 A题很水,几分钟秒了。 B题想到一个解,被自己 hack 掉之后没有重新想,一直想在自己一开始的基础上改好,结果最后B都没拿下。 B. Chip and Ribbon 我的思路 其实也是 ......
Educational Codeforces Round Rated 158

Educational Codeforces Round 158 补题(A~D)

A. 思路 找出最大耗油的路程即可 ac代码 #include <bits/stdc++.h> using namespace std; using i64 = long long; const i64 inf = 8e18; typedef pair<int, int> pii; void sol ......
Educational Codeforces Round 158

Educational Codeforces Round 158 A-D

Educational Codeforces Round 158 A-D A. Line Trip 题意: 有一条路,从0到x,你需要开汽车从0到x再返回0,每个单位距离消耗一升油,出发时汽车满油,中间设有n个加油站,求油箱的最小容积 思路: 油箱中的油至少要能坚持从一个加油站开到下一个加油站,注意 ......
Educational Codeforces Round 158 A-D

Educational Codeforces Round 158 (Rated for Div. 2)

A. Line Trip 题意是:有n个加油点,人要来回两趟,问你最少要多少油? using namespace std; int a[100]; void solve(){ int n,m; cin>>n>>m; for(int i=1;i<=n;i++)cin>>a[i]; int ans=a[ ......
Educational Codeforces Round Rated 158

Educational Codeforces Round 146 补题(A~C)

Educational Codeforces Round 146 (Rated for Div. 2) A. Coins 题目大意 给你两个整数n和k,问你是否存在两个非负整数x和y,使得 2⋅x+k⋅y=n 成立 思路 裴蜀定理秒了,记得开long long ac代码 #include <bits ......
Educational Codeforces Round 146

Educational Codeforces Round 158 (Rated for Div. 2) A-C

A 大致题意: 有一条长度为x的直线公路,最开始你位于0号点并且此时你的油箱装满了油,公路有n个加油站,当你经过加油站的时候你可以在加油站加满油,每走一个单位需要花费1升油量,起始位置和终点没有加油站,请问你的油箱容量至少为多少升才可以够你跑一个来回。 解题思路: 我们的路径大致是这样0 -> a[ ......
Educational Codeforces Round Rated 158

Educational Codeforces Round 158 (Rated for Div. 2) 补题AB

Problem - A - Codeforces 签到题,但是出现了一些问题,测试用例2一直没搞出来 思路很容易想到,汽车油量必须保证能够通过任意相邻的两个加油站,也就是数组里的a[i]-a[i-1]的距离,特殊的,第一次需要将a[0]=0这样进行初始化,其他的使数组从1开始赋值,对应从第一个加油站 ......
Educational Codeforces Round Rated 158

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 Rated Div

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\) ......
Educational Codeforces Round Rated ABCD

Educational Codeforces Round 13 E

tilian 最开始看错了以为是 可以任意选择两人or选择一人胜出 但题意是 可以选择下一个擂主是谁 考虑dp的话 我们显然需要记录一个state以及当前擂主是谁 转移就是 dp[state][i]=max(dp[state][i],dp[state(1<<j)][j]*a[i][j]+dp[sta ......
Educational Codeforces Round 13

Educational Codeforces Round 94 (Rated for Div. 2) D. Zigzags 题解

题意 给你一个数组 \(a1,a2…an\) 请计算有多少个四元组 \((i,j,k,l)\) 符合以下条件: \(1 <= i < j < k < l <= n\) \(a_i=a_k \ \&\&\ a_j=a_l\) \(4<=n<=3000,1<=a_i<=n\) \(input\) 2 5 ......
题解 Educational Codeforces Zigzags Round

Educational Codeforces Round 157 D

tilian 不太会这种题 发现找到一个数就能确定整个序列 然后转而发现 前缀异或和 b1 ^ b2 = a1 b1 ^ b3 = a2 ... 我们发现要是n为偶数时能直接求出b1从而确定整个序列 而为奇数时我们无法确定b1 我们思考拆位之后 如果b1该位为0 算出真实的异或后的0 1 个数 b1 ......
Educational Codeforces Round 157

Educational Codeforces Round 126 (Rated for Div. 2)

https://codeforces.com/contest/1661/ B题数据很小,直接bfs预处理就行 C题随便猜了一下,设mx=\(max\{a_i\}\)最后的值应该是 mx,mx+1,mx+2,mx+3之类的吧 D题刚开始从前面考虑,陷入僵局,一度非常的困,学习凯库勒睡了一会,就突然想到 ......
Educational Codeforces Round Rated 126

Educational Codeforces Round 157 (Rated for Div. 2)

\(D. XOR Construction\) 首先观察 $ b_1 \oplus b_2=a_1, b_2 \oplus b_3=a_2 \ldots $ ,发现 \(b_1 \oplus b_{j+1}=\bigoplus^{j}_{i=1}a_i\) ,那么自然的想到如果第一个数字确定,后面的 ......
Educational Codeforces Round Rated 157

Educational Codeforces Round 67 (Rated for Div. 2) E. Tree Painting

题目链接 Tree Painting 题面翻译 给定一棵 \(n\) 个点的树 初始全是白点 要求你做 \(n\) 步操作,每一次选定一个与一个黑点相隔一条边的白点,将它染成黑点,然后获得该白点被染色前所在的白色联通块大小的权值。 第一次操作可以任意选点。 求可获得的最大权值 思路 假如说,第一次我 ......
Educational Codeforces Painting Round Rated

Educational Codeforces Round 157 (Rated for Div. 2)

A. Treasure Chest 题目大意:人在0处,宝藏在x,钥匙在y,人最多拿宝箱z秒,问你最快多久开宝箱? 思路:如果说钥匙在宝箱的左边,那么人只需要往右走就是最佳答案,如果钥匙在宝箱的右边,那么人只需要拿的宝箱到最佳地点就行 #include<bits/stdc++.h> using na ......
Educational Codeforces Round Rated 157

Educational Codeforces Round 157 (Rated for Div. 2)

F. Fancy Arrays 第一眼感觉是去容斥掉条件 1,因为条件 2 其实挺紧的。 不妨用 \(f(l,r)\) 表示 \(a\) 值域在 \([l,r]\) 的方案(满足条件 2)。 那么答案为 \(f(0,+\infty)-f(0,x-1)-f(x+k,+\infty)\),因为如果选了 ......
Educational Codeforces Round Rated 157

Educational Codeforces Round 157 (Rated for Div. 2)

添加链接描述 B题直接前缀后缀预处理一下没了 C 首先题目保证有解,那么我们可以确定"("和")"的数量,显然前面全部填(后面的全部填)肯定是合法的,然后交换两个最近的,影响最小,判断一下即可。 D题首先根据%k余数判断是否有解, 然后肯定是直接往下走到最大,然后走过去,rmq预处理即可。 ......
Educational Codeforces Round Rated 157

Educational Codeforces Round 157 (Rated for Div. 2) D. XOR Construction

原题链接 解读一下题意:给一个长度n-1的数组,让你找到一个长度为n的数组b,并且是0到n-1的全排列,使得bi异或bi+1对于ai。 这道题乍一看没什么思路,但是仔细一想会发现其实考察的就是异或的性质。我们可以发现:如果a异或b等于c,那么abc任意两个异或都能得到另外一个,所以只要初始的b0确定 ......

Educational Codeforces Round 157 (Rated for Div. 2)

Preface 懒狗闪总好久没打CF了,而且桂林回来后也没摸过键盘了,今天打的那叫一个手生 本来都不知道今天晚上有比赛,后面ztc叫我打我想着反正不熄灯就小号摆着打 最后赛后10min写出E题就很难受,感觉状态正常点就能出5个题了(或者来个2h15min的场就好了) A. Treasure Ches ......
Educational Codeforces Round Rated 157

Educational Codeforces Round 157 (Rated for Div. 2)

A. Treasure Chest 分类讨论一下,只有两种情况。 走到钥匙处,然后走到箱子处 走到箱子处,移动箱子,走到钥匙处,走回箱子处 对于第二种情况可以直接枚举箱子被移动到的位置 #include <bits/stdc++.h> using namespace std; #define int ......
Educational Codeforces Round Rated 157

Educational Codeforces Round 157 (Rated for Div. 2) D. XOR Construction

题目链接 题意 给你 \(n-1\) 个整数 \(a_1, a_2, \dots, a_{n-1}\) 。 你的任务是构造一个数组 \(b_1, b_2, \dots, b_n\) ,使得: 从 \(0\) 到 \(n-1\) 的每个整数都在 \(b\) 中出现一次; 对于从 \(1\) 到 \(n ......

Educational Codeforces Round 134 (Div.2) D 题解

题目链接 D. Maximum AND 题目大意 给定两组序列 \(a\) \(b\),长度为 \(n\) ,现有一新序列 \(c\),长度也为 \(n\) 。 其中,\(c_i = a_i \oplus b_i\) 。 定义 \(f(a,b) = c_1\&c_2\&……\&c_n\)。 现在你可 ......
题解 Educational Codeforces Round 134

Educational Codeforces Round 128 (Rated for Div. 2)

添加链接描述 C题显然二分0的数量,然后双指针,算一下前缀和后缀1的数量即可。 #include<cstdio> #include<algorithm> #include<cstring> #include<cmath> #include<map> #include<vector> #include ......
Educational Codeforces Round Rated 128

Educational Codeforces Round 129 (Rated for Div. 2)

Educational Codeforces Round 129 (Rated for Div. 2) B可以看作一个无限长的序列由a进行重复拼接,我们直接计算一下是哪个即可。 C判断无解之后直接模拟即可 D IDA*就行每次从大到小搜,实际非常快。 #include<cstdio> #includ ......
Educational Codeforces Round Rated 129

Educational Codeforces Round 127(CF1671 D~E) 题解

D. Insert a Progression 题目链接 可以瞪出来的一个结论就是当我们在位置 \(p\) 插入了一个数 \(x\) 时,如果存在一对 \(l,r\) 满足 \(l<p\),\(r>p\) 且 \(x\in[a_l,a_r]\),那么我们插入的这个 \(x\) 就不会对序列的答案产生 ......
题解 Educational Codeforces Round 1671

Educational Codeforces Round 144(CF1796 D~E) 题解

D. Maximum Subarray 题目链接 十分钟秒了一道 *2000,非常爽,但是个人感觉确实非常简单。 下面令 \(b_i=a_{i}-x\),\(b_i'=a_i+x\) 。 因为 \(k<=20\),因此考虑一个复杂度与 \(k\) 相关的做法。 不妨 dp:设 \(f_{i,j,0/ ......
题解 Educational Codeforces Round 1796

Educational Codeforces Round 145 (Rated for Div. 2) B. Points on Plane

给一个二维平面,你需要在上面放 \(n\) 个芯片。将一个芯片放在 \((x, y)\) 的代价为 \(|x| + |y|\) 。放 \(n\) 个代价的代价为,所有芯片中耗费的最大代价。并且你需要保证任意两个芯片之间的距离严格 \(> 1\) 。 现在给出 \(n\) 给芯片,询问放 \(n\) ......
Educational Codeforces Points Round Rated

Educational Codeforces Round 149 (Rated for Div. 2)

这场D被切穿了。 A题 答案为 x 或者 x-1 1 B题 答案就是最长的连续一段的长度+1 证明的话大概可以将它看成是几段连续上升和下降的段,然后在峰谷、峰顶分别填上最小、最大,剩下的就依次递增或递减就行。 C题 将一段连续的0/1视作一个块,那么我们最小化这个块的数量就行。 D题如果猜到如果有解 ......
Educational Codeforces Round Rated 149