
codeforces
Error Man
我是菜逼
展开
-
Gym 101889E. Enigma (dp => 思维)
题意: 有长度为最多为 1000位的大数,其中某些位是 ?,表示可以是 0 ~ 9 中的任意一个数. 给一个数 n,将所有的 ? 都填上,使得最后满足这个大数是 n 的倍数 (至少1倍),同时最小化这个大数 (不含前导 0)Analyse:容易想到的是 dp 做法。dp[i][j] 表示当前到第 i 位,mod n == j 的最小数,转移也并不复杂。但是问题来了,这个数是一个大数,存不下怎...原创 2019-10-23 23:03:59 · 218 阅读 · 0 评论 -
Gym 101889F. Fundraising(线段树 + dp)
题意: n 个人,每一个人都 x , y , v 三个属性. 现在要选取若干个人形成一个集合,这个集合需要满足的条件是,集合内的任意两个人A,B都符合 (A.x == B.x && A.y == B.y) || (A.x < B.x && A.y < B.y) || (A.x > B.x && A.y > B.y),最大化集...原创 2019-10-23 15:40:30 · 212 阅读 · 0 评论 -
codeforces Educational Codeforces Round 64 (Rated for Div. 2) C (水题 暴力可过)
C. Match Pointstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a set of points x1, x2, ..., xn on the number line.Two points ...原创 2019-05-24 11:33:28 · 193 阅读 · 0 评论 -
Codeforces Round #564 (Div. 2) C. Nauuo and Cards(二分)
C. Nauuo and CardsNauuo is a girl who loves playing cards.One day she was playing cards but found that the cards were mixed with some empty ones.There are n cards numbered from 1 to n, and they ...原创 2019-06-08 12:00:52 · 244 阅读 · 0 评论 -
Codeforces 1185 C2. Exam in BerSU (hard version)(权值线段树 + 二分 查询前 K 大的和)
题目:题目链接题意:给定一个长度为 n 的数组 a 和 一个数 M,问对于每一个 i ,在区间 [1,i - 1] 删除最少的数,使得[1,i - 1]中剩下的数的和 + a[i] <= M,问最少删除多少个数。思路:显然要删除最少个数,肯定是从大到小进行删除,关键就是怎么确定从大到小的数的和,这就是需要解决的问题。那么我是用权值线段树来进行维护的如整个区间第 k 大一样,然后查询的...原创 2019-07-09 22:40:57 · 463 阅读 · 0 评论 -
codeforces 227 C Flying Saucer Segments ,E Anniversary (矩阵快速幂)
目录C.Flying Saucer SegmentsE.AnniversaryC.Flying Saucer SegmentsAn expedition group flew from planet ACM-1 to Earth in order to study the bipedal species (its representatives don't even have an...原创 2019-08-04 22:14:55 · 256 阅读 · 1 评论 -
CodeForces - 780C Andryusha and Colored Balloons ( dfs )
Andryusha and Colored BalloonsAndryusha goes through a park each day. The squares and paths between them look boring to Andryusha, so he decided to decorate them.The park consists of n squares con...原创 2018-08-25 19:43:47 · 209 阅读 · 0 评论 -
Codeforces Round #574 (Div. 2) E - OpenStreetMap (单调队列,求子矩阵最小值的和)
E. OpenStreetMapSeryozha conducts a course dedicated to building a map of heights of Stepanovo recreation center. He laid a rectangle grid of sizen×mn×mcells on a map (rows of grid are numbered fro...原创 2019-07-23 11:07:22 · 373 阅读 · 0 评论 -
2019湖南多校第4场(codeforces gym 101158)部分题解
目录A题:题目链接B题:题目链接C题:题目链接D题:题目链接A题:题目链接题意:给定一个整数 n,代表有一个序列 1,2,3,4,...,n ,然后给定一个整数m, 接下来有 m 个数,代表把数 x 放在最前面。问最后这个序列是怎么样的。 ( n范围为 2e5)思路:这是个煞笔题,开一个 4e5 + 10 的数组,数组起点设为 2e5, 输入放在 2e5后面,操作的数放...原创 2019-03-31 17:57:31 · 555 阅读 · 1 评论 -
Codeforces 86 D.Powerful array(莫队算法)
Powerful arrayAn array of positive integersa1, a2, ..., anis given. Let us consider its arbitrary subarrayal, al + 1..., ar, where1 ≤ l ≤ r ≤ n. For every positive integersdenote byKsthe num...原创 2019-08-06 11:19:49 · 282 阅读 · 0 评论 -
codeforces 617 E.XOR and Favorite Number(莫队算法)
E. XOR and Favorite NumberBob has a favorite numberkandaiof lengthn. Now he asks you to answermqueries. Each query is given by a pairliandriand asks you to count the number of pairs of in...原创 2019-08-05 23:02:07 · 173 阅读 · 0 评论 -
CodeForces - 1008C Reorder the Array (思维)
Reorder the ArrayYou are given an array of integers. Vasya can permute (change order) its integers. He wants to do it so that as many as possible integers will become on a place where a smaller integ...原创 2018-11-12 20:10:54 · 213 阅读 · 0 评论 -
CodeForces - 1060C Maximum Subrectangle (前缀和 + 思维 + 暴力)
Maximum SubrectangleYou are given two arrays aa and bb of positive integers, with length nnand mm respectively.Let cc be an n×mn×m matrix, where ci,j=ai⋅bjci,j=ai⋅bj.You need to find a subrectan...原创 2018-11-14 17:25:47 · 488 阅读 · 0 评论 -
CodeForces - 777C Alyona and Spreadsheet (暴力 ,预处理)
Alyona and SpreadsheetDuring the lesson small girl Alyona works with one famous spreadsheet computer program and learns how to edit tables.Now she has a table filled with integers. The table cons...原创 2018-08-25 21:06:15 · 232 阅读 · 0 评论 -
CodeForces - 1040B Shashlik Cooking (贪心 + 细节)
Shashlik Cooking Long story short, shashlik is Miroslav's favorite food. Shashlik is prepared on several skewers simultaneously. There are two states for each skewer: initial and turned over.Thi...原创 2018-09-17 15:40:10 · 474 阅读 · 0 评论 -
codeforces 1005D Polycarp and Div 3
Polycarp likes numbers that are divisible by 3.He has a huge number ss. Polycarp wants to cut from it the maximum number of numbers that are divisible by 33. To do this, he makes an arbitrary number...原创 2018-10-02 13:17:52 · 251 阅读 · 1 评论 -
CodeForces - 1006C Three Parts of the Array (前缀和 + 尺取思想)
Three Parts of the ArrayYou are given an array d1,d2,…,dn consisting of n integer numbers.Your task is to split this array into three parts (some of which may be empty) in such a way that each ele...原创 2018-09-28 21:17:14 · 292 阅读 · 0 评论 -
CodeForces - 1005C Summarize to the Power of Two (贪心 + 离散化)
Summarize to the Power of TwoA sequence a1,a2,…,an is called good if, for each element ai, there exists an element aj (i≠j) such that ai+aj is a power of two (that is, 2d for some non-negative integ...原创 2018-09-28 19:33:31 · 331 阅读 · 0 评论 -
CodeForces - 1060B Maximum Sum of Digits (思维。)
B. Maximum Sum of DigitsYou are given a positive integer n.Let S(x) be sum of digits in base 10 representation of x, for example, S(123)=1+2+3=6, S(0)=0.Your task is to find two integers a,b, su...原创 2018-11-03 13:54:15 · 399 阅读 · 0 评论 -
codefores 1073C (二分 + 前缀和)
C. Vasya and Robottime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputVasya has got a robot which is situated on an infinite Cartesian plane, i...原创 2018-11-10 19:39:00 · 334 阅读 · 0 评论 -
codeforces 1068C Colored Rooks (思维构造题)
Colored RooksIvan is a novice painter. He has nn dyes of different colors. He also knows exactly mm pairs of colors which harmonize with each other.Ivan also enjoy playing chess. He has 50005000 r...原创 2018-11-11 17:55:08 · 569 阅读 · 0 评论 -
Codeforces 224E.Partial Sums(组合数学+费马小定理,重复 k 次前缀和)
E.Partial SumsYou've got an arraya, consisting ofnintegers. The array elements are indexed from 1 ton. Let's determine a two step operation like that:First we build by the arrayaan arrayso...原创 2019-08-03 20:09:40 · 434 阅读 · 0 评论 -
Codeforces 1114C (n阶乘在b进制下的末尾0数)
传送门题意:n阶乘在b进制下的末尾0数目思路:主要是理解一下进制的问题,一个数在b进制下含0,意思就是 能够整除b,那么自然可以想到。。。。这个题就是求n阶乘内能够包含多少个b。假如b的质因子是a1和a2分别出现b1,b2次,然后就求n!里a1和a2分别出现cn1,cnt2次,cnt1/b1和cnt2/b2之间的最小值就是n阶乘里b的个数了。。。这里我的代码丑的难看,就不要看了,...原创 2019-03-08 22:14:25 · 458 阅读 · 1 评论 -
Codeforces 484D.Kindergarten(dp,一个数组分成若干段,每一段的值是这一段的max - min,极大化所有段的和)
D.KindergartenIn a kindergarten, the children are being divided into groups. The teacher put the children in a line and associated each child with his or her integer charisma value. Each child should...原创 2019-08-20 00:15:18 · 243 阅读 · 0 评论 -
Codeforces 1051D.Bicolorings(dp计数,状态压缩)
Bicolorings题目描述You are given a grid, consisting of 2 2 rows and n n columns. Each cell of this grid should be colored either black or white.Two cells are considered neighbours if they have a common...原创 2019-08-20 20:43:14 · 327 阅读 · 0 评论 -
Codeforces 10D - LCIS(最长公共上升子序列 + 路径输出)
LCISThis problem differs from one which was on the online contest.The sequence a1, a2, …, an is called increasing, if ai < ai + 1 for i < n.The sequence s1, s2, …, sk is called the subsequenc...原创 2019-08-21 23:45:48 · 577 阅读 · 0 评论 -
Codeforces 1154E.Two Teams(思维,两个set 直接艹)
Two Teams题目链接:点我看题题意: nnn 个人有编程能力 aia_iai,排成一行。两个教练 AAA 和 BBB,教练 AAA 先手,每一次选这一行中的最大编程能力的人,然后再向左右两选取 kkk 个人,不足 kkk 个则全部选取,选取了的人就离开。然后教练 BBB 做相同的操作。 输出 最后每个人属于的教练,AAA输出 111,BBB 输出 222.思路:考虑到每次都需要...原创 2019-08-30 16:22:57 · 347 阅读 · 0 评论 -
Codeforces 1207 C. Gas Pipeline(简单dp)
题目链接题意: 给一个长度为 nnn 的 010101 串,和建单位长度的管道的代价 aaa 和单位长度的柱子 bbb 的代价,有 444 种柱子,低管道代价为 a+ba+ba+b ,高管道代价为 a+2∗ba+2*ba+2∗b,上升管道代价为2∗a+b2*a+b2∗a+b,下降管道代价为2∗a+2∗b2*a+2*b2∗a+2∗b, 010101串中 111 代表要建高管道,一段高管道前要建上升...原创 2019-09-02 21:32:28 · 307 阅读 · 0 评论 -
Codeforces 1208D.Restore Permutation (构造数组[每个数属于1~n],满足 i 位置前缀小于 B[i] 的数的和 == A[i])
Restore Permutation题目连接题意: 有一个数组未知数组 B,给一个数组AAA,A[i]A[i]A[i] 表示 iii 的前缀比 B[i]B[i]B[i] 小的数的和。还原数组 B, 满足数组 A 这个条件。思路: 和 HDU 5592 区别不大。从后往前还原,假设现在还原的是最后一个数 x ,那么二分枚举这个数 x ,满足条件 A[n]A[n]A[n] 即可,然后删掉 x,...原创 2019-09-05 19:14:15 · 331 阅读 · 0 评论 -
Codeforces 1200D. White Line(思维 + 前缀和)
戳我看题题意: 给一个字符矩阵,只含有 W 和 B,现在有一种操作,将一个 k * k 矩阵全部变为 W,问最多能有多少个行和列全部为 W思路: 可以单独算每一个点的贡献。以行为例:先算的每一行的 B 的前缀和,枚举这一行的所有点,若 prex[j+k−1]−prex[j−1]==prex[n] && prex[n]!=0prex[j ...原创 2019-09-07 21:10:32 · 253 阅读 · 0 评论 -
Codeforces 546E.Soldier and Traveling(网络流最大流)
Soldier and TravelingIn the country there are n cities and m bidirectional roads between them. Each city has an army. Army of the i-th city consists of ai soldiers. Now soldiers roam. After roaming e...原创 2019-10-03 11:18:48 · 344 阅读 · 0 评论 -
Codeforces 5C.Longest Regular Bracket Sequence(最长连续合法括号匹配[dp + stack])
Longest Regular Bracket SequenceThis is yet another problem dealing with regular bracket sequences.We should remind you that a bracket sequence is called regular, if by inserting «+» and «1» into it...原创 2019-08-20 14:43:34 · 343 阅读 · 0 评论 -
Codeforces 940E. Cashback(贪心 + dp)
E. CashbackSince you are the best Wraith King, Nizhniy Magazin «Mir» at the centre of Vinnytsia is offering you a discount.You are given an array a of length n and an integer c.The value of some ar...原创 2019-08-20 17:49:02 · 315 阅读 · 0 评论 -
CodeForces - 67A. Partial Teacher (差分约束系统)
Partial TeacherA teacher decides to give toffees to his students. He asksnstudents to stand in a queue. Since the teacher is very partial, he follows the following rule to distribute toffees.He ...原创 2019-08-10 21:28:25 · 435 阅读 · 0 评论 -
codeforces 467 C.George and Job (dp, k 段长度为 m 的不相交的子段最大和)
链接链接题意:给一个数组,长度为 n ,现在要选择 k 段长度为 m 的不相交的子段,问最大和是多少。思路:dp[i][k] 表示到i 个数,选取 k 段的最大和。有状态转移方程 dp[i][k] = max(dp[i - 1][k],dp[i - m][k - 1] + pre[i] - pre[i - m]) . 其中 pre 表示前缀和。Code:#inclu...原创 2019-07-31 10:48:47 · 375 阅读 · 1 评论 -
codeforces 1183 H. Subsequences (hard version)(dp求不重复子序列数量)
H. Subsequences (hard version)The only difference between the easy and the hard versions is constraints.A subsequence is a string that can be derived from another string by deleting some or no sym...原创 2019-07-29 22:41:49 · 263 阅读 · 1 评论 -
Codeforces 1182 E. Product Oriented Recurrence(矩阵快速幂 + 欧拉降幂 + 快速幂)
E. Product Oriented RecurrenceLetfx=c2x−6⋅fx−1⋅fx−2⋅fx−3fx=c2x−6⋅fx−1⋅fx−2⋅fx−3forx≥4x≥4.You have given integersnn,f1f1,f2f2,f3f3, andcc. Findfnmod(109+7)fnmod(109+7).InputThe only li...原创 2019-07-23 20:20:23 · 633 阅读 · 0 评论 -
codeforces 580E (线段树 + 字符串哈希)
======>蒟蒻的博客,写错的地方,请见谅。题目:传送门题意:给你三个整数n,m,k, n 代表一个字符串的长度为n。紧接着有 m + k 个操作。将 l 到 r 的字符全部更换为字符 c ,或查询从 l 到 r,该子段字符串循环节是否为 c.思路:由于该蒟蒻很少写哈希,而且又很菜,花了挺长时间写这个题目的,也算是有挺大的收获,对多项式哈希理解很多。多项式哈希,即:...原创 2019-03-26 16:16:43 · 461 阅读 · 0 评论 -
Codeforces - 41 D. Pawn(dp[刷表] + 路径输出)
PawnOn some square in the lowest row of a chessboard a stands a pawn. It has only two variants of moving: upwards and leftwards or upwards and rightwards. The pawn can choose from which square of th...原创 2019-08-13 14:03:39 · 314 阅读 · 0 评论 -
Codeforces 940 F - Machine Learning(带修改莫队, 及注意事项)
F - Machine LearningYou come home and fell some unpleasant smell. Where is it coming from?You are given an arraya. You have to answer the following queries:You are given two integerslandr. L...原创 2019-08-06 21:07:04 · 284 阅读 · 0 评论