注:两道题目题意是一样的,但是数据范围不同,一个为弱化版,另一个为强化版. P3146传送门(弱化版) 思路: 区间动规,设 f [ i ][ j ] 表示在区间 i ~ j 中获得的最大值,与普通区间动规最大的不同在于:只有左区间的最大值等于右区间的最大值时才能够进行转移. AC代码: #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> #include<cst…
P3147 [USACO16OPEN]262144一道非常有趣的游戏,不,题目.当数据水时,可以这样表示状态.f[i][j]表示合并[i,j]区间所能得到的最大值,有点floyed的小味道.if(f[i][k]==f[k+1][j])f[i][j]=max(f[i][k]+1,f[i][j]);不断更新答案.这样需要枚举左右端点和中间点,O(n^3)300以内的数据可以水过.状态的设定直接把dp拉到暴力里去了. #include<iostream> #include<cstdio>…
P3147 [USACO16OPEN]262144 题目描述 Bessie likes downloading games to play on her cell phone, even though she doesfind the small touch screen rather cumbersome to use with her large hooves. She is particularly intrigued by the current game she is playing.…
P3146 [USACO16OPEN]248 题目描述 Bessie likes downloading games to play on her cell phone, even though she doesfind the small touch screen rather cumbersome to use with her large hooves. She is particularly intrigued by the current game she is playing.The…
P3147 [USACO16OPEN]262144 题目描述 Bessie likes downloading games to play on her cell phone, even though she doesfind the small touch screen rather cumbersome to use with her large hooves. She is particularly intrigued by the current game she is playing.…
P3146 [USACO16OPEN]248 题目描述 Bessie likes downloading games to play on her cell phone, even though she doesfind the small touch screen rather cumbersome to use with her large hooves. She is particularly intrigued by the current game she is playing.The…
P3146 [USACO16OPEN]248 题解 第一道自己码出的区间DP快庆祝一哈 2048 每次可以合并任意相邻的两个数字,得到的不是翻倍而是+1 dp[L][R] 区间 L~R 合并结果 然后拆成左区间和右区间,看看他们能不能合并,更新ans 注意如果最后枚举到的总区间 1~n ,那么就要考虑取左右区间最大值了,因为可能左右区间不能合并,那么左右区间最大值就是最终答案 代码 #include<iostream> #include<cstdio> #include<st…
[USACO16OPEN]248 G 题目描述 Bessie likes downloading games to play on her cell phone, even though she doesfind the small touch screen rather cumbersome to use with her large hooves. She is particularly intrigued by the current game she is playing.The gam…
[USACO16OPEN]248 G 题目: 题目描述 Bessie likes downloading games to play on her cell phone, even though she doesfind the small touch screen rather cumbersome to use with her large hooves. She is particularly intrigued by the current game she is playing.The…
https://www.luogu.org/problemnew/show/P3147 此题与上一题完全一样,唯一不一样的就是数据范围; 上一题是248,而这一题是262144; 普通的区间dp表示状态表示法根本存不下, 这时我们就要想另外的状态表示法; #include <bits/stdc++.h> #define read read() #define up(i,l,r) for(int i = (l);i <=(r); i++) using namespace std; int…