- 博客(30)
- 收藏
- 关注
原创 Max Sum Plus Plus-HDU 1024(思考:前缀模型优化,延迟更新)
最大m子段和二维空间不够前缀模型优化,延迟更新dp[i][j]dp[i][j]dp[i][j]到第jjj个数,组成iii段时的最大和dp[i][j]=max(dp[i][j−1],max{dp[i−1][k−1]}+a[j] (i<=k<=j))dp[i][j]=max(dp[i][j-1],max\{dp[i-1][k-1]\}+a[j] \ \ \ \ \ (i<=k<=j))dp[i][j]=max(dp[i]
2021-06-12 21:43:18
134
1
原创 2021-06-11
在宿舍打得真艰难,刚开始心里乱糟糟的,根本静不下来,第一题吭哧吭哧半天,心凉了半截,本以为又要掉大分,后面有点进入状态,二分把c过了,看b挺长的,没想到水得不行,f找规律用前缀思想计数,算是小翻盘,最后d题思路不是很明确,没想出来。这次打得很艰难,但没想到还刷新了我的出题记录。最近也在找cf中高分题做,开阔下眼界,vj做了些单调栈单调队列和STL的,感觉还行。比较懒,不太想写博客。为防止肩膀酸,晚上去拉了拉单杠伸展伸展。快考试了,一点没复习,有种无形的压力,感觉自己在逃避考试。...
2021-06-11 01:05:25
189
原创 5月23日总结
//一般二分//[0,n)//a={1 2 2 2}//n= 0 1 2 3 4//mid=2//l=0 r=2//mid=1//l=0 r=1//mid=0//l=1 r=1//return 1int lowb(int a[],int len,int k){//下界 int l=0,r=len,mid; while(l<r){ mid=(r+l)/2; if(a[mid]>k)r=mid; else if(
2021-05-23 15:22:39
81
原创 滑动窗口问题(单调队列)
An array of size n ≤ 106 is given to you. There is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k numbers in the window. Each time the sliding window moves rightwards by one position. F.
2021-05-22 16:00:30
170
原创 Educational Codeforces Round 109(C. Robot Collisions)
Educational Codeforces Round 109(C. Robot Collisions)题意数轴0,1,2,...,n−1,n0,1,2,...,n-1,n0,1,2,...,n−1,n上每个点有一个机器人,每个机器人有左右两个运动方向,碰到x=0,nx=0,nx=0,n时,会掉头。当两个机器人恰好同时走到一个点时,两个机器人会消失,起始时间为000,问每个机器人消失的时间是多少,如果不会消失则时间置为−1-1−1。当时时间结束了,想到了只有同位奇数或偶数位置机器人才有相撞的可能,
2021-05-20 21:31:34
109
原创 Educational Codeforces Round 109(D. Armchairs)
计算将所有1与0匹配的最小距离和#include<bits/stdc++.h>using namespace std;#define ll long long#define pii pair<int,int>#define inf 0x3f3f3f3f#define rush() int T;cin>>T;while(T--)#define pb push_back#define mp make_pair#define ms(a,x) memset(a,
2021-05-19 17:44:02
132
原创 Sumdiv 二分
Consider two natural numbers A and B. Let S be the sum of all natural divisors of A^B. Determine S modulo 9901 (the rest of the division of S by 9901).InputThe only line contains the two natural numbers A and B, (0 <= A,B <= 50000000)separated b.
2021-05-17 20:33:57
96
1
原创 5月16日总结
比赛那天到牛客上看了排行榜,那种感受很微妙。上一次看榜是在某个编程闲聊群里,那时候好像是区域赛,一些群友就聊起来,无意间看到一个排行榜的链接,怀着好奇心点进去,看到好多学校,基本都是985/211这种,想看下有没有我们学校,搜了下,发现我们学校也在,队名叫秋天的第一个AC,A了5题,排名相对在中上吧,感觉都是大佬。虽然比榜一少了4题,但排名拉的很大。...
2021-05-17 10:47:11
688
3
原创 Codeforces Round 108 (C. Berland Regional)
题意:给出数组uuu和sss,对应位置(ui,si)(u_i,s_i)(ui,si)表示该学生在学校uiu_iui,能力为sis_isi,学校按每kkk(1≤k≤n)(1\leq k \leq n)(1≤k≤n)人分组,少于kkk人不能组队,依次求出按kkk分,所有学校的参赛队伍最大能力总和。STL+模拟+前缀和#include<bits/stdc++.h>using namespace std;#define ll long long//学校编号去重(set)//按学校编号
2021-04-30 20:16:30
143
1
原创 Codeforces Round 108(Problem - D Maximum Sum of Products)
题意:给定长度为nnn的数组a,ba,ba,b,你可以通过反转aaa的一段连续子序列,来求得max∑i=1nai⋅bimax\sum_{i=1}^{n}a_i·b_imax∑i=1nai⋅bi区间DP注意:三重循环会TLE优化:计算小区间的反转与未反转的差,每次都利用中间的部分,左右端点另算,减少重复计算。#include<bits/stdc++.h>using namespace std;#define ll long longint a[5005],b[5005];ll
2021-04-30 19:07:31
90
1
原创 4月25日总结
区间DP是DP的一个特例,所以框架比较固定,但每个模型还是有些细节的差异。想明白每个区间的状态如何转移、如何合并成大区间、怎么划分区间(一次划分、嵌套划分),就很好写程序了。发现有些题,数据规模很小,但是一个状态可能由好几个状态转移过来,一般都要开三四维数组,这时候用for循环写DP就不是很好写,需要用深搜dfs,配合记忆化搜索,用自顶向下递归来代替自底向上递推,比DP更好理解。CF读题choose 2 different elements in the array我理解的意思:在数组中选两
2021-04-25 16:45:56
109
原创 Codeforces_327A(前缀+区间DP)
题意给定一个序列,只有01,必须选定一个区间取反,求最多有几个1找到一个区间(0的个数减1的个数之差最大),加上之前的的1个数即可//#pragma GCC optimize(2)//#pragma GCC optimize(3,"Ofast","inline")#include<iostream>#include<cstring>#include<algorithm>#include<map>#include<set>#..
2021-04-19 19:15:09
116
原创 Codeforces_1478B
题意每个测试例,给出一系列数和一个幸运数字,如果这个数能等于若干小于它的并且含有幸运数字的数之和,输出YES,否则NO。注意数据规模非常大,暴力是不能的。既然是数学题,必然要用到一些技巧。目前能力有限,只能看出规律,而无法严格证明。规律:设幸运数字为d,如果正整数x≥10d,则x=∑yi(yi≤x,yi=⋯d⋯⏟)yi小于等于x,且某一位含有d设幸运数字为d,如果正整数x \geq 10d,\\则x=\sum y_i\\(y_i\leq x,y_i= \underbrace {\cdots ..
2021-04-19 16:45:27
119
2
原创 4月17日总结
反思感觉CF前两题都是思维题,一般模拟就行,但有时漏了细节条件,就怎么也想不出哪里有问题。现在,做题只会简单题,作业里的难题想半天想不出来,CF的题解只能看懂前三个,再看做过的作业题,有些具体细节也忘了,只知道大概怎么做,不能立刻出代码。这样下去肯定不行!我在想,一道题到底要做几遍、想几遍、怎么做才能熟练题型,怎么样才能学透做过的题,然后举一反三,独立解决没做过的难题;记住所有做过的题是不可能的,就算硬记住了,也只是积累了经验,也不会有启发式的新思维来做新题。继承和创新的矛盾怎么协调,我还需要很
2021-04-17 19:30:47
64
原创 FZU2234 牧场物语(双线DP)
FZU2234 牧场物语小茗同学正在玩牧场物语。该游戏的地图可看成一个边长为n的正方形。小茗同学突然心血来潮要去砍树,然而,斧头在小茗的右下方。小茗是个讲究效率的人,所以他会以最短路程走到右下角,然后再返回到左上角。并且在路上都会捡到/踩到一些物品,比如说花朵,钱和大便等。物品只能被取最多一次。位于某个格子时,如果格子上还有物品,就一定要取走。起点和终点上也可能有物品。每种物品我们将为其定义一个价值,当然往返之后我们取得的物品的价值和越大越好。但是小茗同学正在认真地玩游戏,请你计算出最大的价值和
2021-04-15 21:42:27
123
原创 4月10日总结
总结动态规划的理解:每一时刻都选择一个最好的过去,来决定该时刻。不要被题意受限制,比如钓鱼贪心,虽然是单向,但是计算方式和现实是不一样的,而是抽象模型,转换求解,这类问题要小心,十分迷惑人的思路。正向思维,逆向思维。基础感受...
2021-04-10 18:31:20
68
原创 3月27号总结
每周总结 第一场CFdiv3比赛打完后,感慨良多,最后结果A了一道签到题a题,wrong了一个c题(过样例时,信心满 满,test2就wrong了,很气),b题没读明白(结束后,才知道贪心,搞了这么久贪心,还是没做出来这个题,很气),d题读懂了(最初思路是桶记录每个数出现次数,发现开不了这么大的数组,然后就不知所措,结束后看题解,用了map和优先队列,太妙了,感觉STL白学了,没想到能这么用,涨知识了),后面的题大体看了看无从下手。反正就是要么没读明白题,要么是读明白了但没想明白怎么写,要么写了但
2021-03-26 20:33:48
99
原创 贪心算法K题
“今年暑假不AC?”“是的。”“那你干什么呢?”“看世界杯呀,笨蛋!”“@#$%^&*%…”确实如此,世界杯来了,球迷的节日也来了,估计很多ACMer也会抛开电脑,奔向电视了。作为球迷,一定想看尽量多的完整的比赛,当然,作为新时代的好青年,你一定还会看一些其它的节目,比如新闻联播(永远不要忘记关心国家大事)、非常6+7、超级女生,以及王小丫的《开心辞典》等等,假设你已经知道了所有你喜欢看的电视节目的转播时间表,你会合理安排吗?(目标是能看尽量多的完整节目)Input输入数据.
2021-03-22 11:32:40
124
原创 贪心算法J题
Ignatius has just come back school from the 30th ACM/ICPC. Now he has a lot of homework to do. Every teacher gives him a deadline of handing in the homework. If Ignatius hands in the homework after the deadline, the teacher will reduce his score of the fi.
2021-03-22 11:18:30
161
原创 贪心算法I题
Suppose there are M people, including you, playing a special card game. At the beginning, each player receives N cards. The pip of a card is a positive integer which is at most N*M. And there are no two cards with the same pip. During a round, each player.
2021-03-22 10:55:08
196
原创 贪心算法H题
There is a pile of n wooden sticks. The length and weight of each stick are known in advance. The sticks are to be processed by a woodworking machine in one by one fashion. It needs some time, called setup time, for the machine to prepare processing a sti.
2021-03-22 10:20:14
358
原创 3月18日每周总结
总结目前遇到的问题模型(贪心算法需要对数据先按一定规则排序)区间调度问题:一连串起始位置,终点位置,求最多进行几个活动…安放雷达…搬运桌子…截止时间问题:设一个date数组,写一个Finddate函数,用并查集思想查找合适未使用的时间,下标用来标记初始可用时间,每次使用完后,该处数组值要减一。。。遇到新的我再整理感受经过两个周的刷题,或多或少都对做题有了那么一点感觉,碰到类似的变形题都会有确切的思路,但是遇到难题,还是没有思路,大部分是因为读不懂题,即使翻译全文,也没完全把握整道题的突破口
2021-03-18 18:14:17
96
原创 贪心算法G题
这题折磨我很久,图没看懂,所以说,题意理解错了,怎么写也是白费功夫The famous ACM (Advanced Computer Maker) Company has rented a floor of a building whose shape is in the following figure.The floor has 200 rooms each on the north side and south side along the corridor. Recently the Co
2021-03-16 21:33:25
212
原创 贪心算法F题
FatMouse prepared M pounds of cat food, ready to trade with the cats guarding the warehouse containing his favorite food, JavaBean.The warehouse has N rooms. The i-th room contains J[i] pounds of JavaBeans and requires F[i] pounds of cat food. FatMouse d.
2021-03-16 21:02:02
269
原创 贪心算法C题
Assume the coasting is an infinite straight line. Land is in one side of coasting, sea in the other. Each small island is a point locating in the sea side. And any radar installation, locating on the coasting, can only cover d distance, so an island in th.
2021-03-16 20:29:21
144
原创 贪心算法D题
Farmer John has a problem: the dirt road from his farm to town has suffered in the recent rainstorms and now contains (1 <= N <= 10,000) mud pools.Farmer John has a collection of wooden planks of length L that he can use to bridge these mud pools. .
2021-03-16 18:39:15
123
原创 贪心算法B题
A supermarket has a set Prod of products on sale. It earns a profit px for each product x∈Prod sold by a deadline dx that is measured as an integral number of time units starting from the moment the sale begins. Each product takes precisely one unit of ti.
2021-03-16 18:06:46
209
原创 贪心算法A题
Farmer John has received a noise complaint from his neighbor, Farmer Bob, stating that his cows are making too much noise.FJ’s N cows (1 <= N <= 10,000) all graze at various locations on a long one-dimensional pasture. The cows are very chatty anim.
2021-03-16 17:07:45
59
原创 C++STL基础实操
string#include <iostream>#include<string>using namespace std;int main(){ ios::sync_with_stdio(false); //初始化1 string a; char b[100]; cin>>b; a=b; cout<<"a="<<a<<endl; //初始化2 string
2021-03-13 20:04:19
77
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人