摘要: dp[x]表示1-x的划分最大和,最多从前面10个位置转移过来#include #include #include #include #include #define ll long long#define MAX_INT 2147483647using namespace std;int n,l;string s;ll dp[210],num[210][210];ll DP(int x){ if(x<=9&&num[0][x]<=MAX_INT) return num[0][x]; if(dp[x]!=-1) return dp[x]; ll ret=0; for 阅读全文
posted @ 2014-02-08 16:37 wonderzy 阅读(169) 评论(0) 推荐(0) 编辑
摘要: 用dp[x][y]表示以(x,y)点为右下角,所形成的图形的最大边长#include #include #include using namespace std;int n;char s[502][502];int dp1[502][502],dp2[502][502];int DP1(int x,int y){ if(s[x][y]=='.') return 0; if(x==0||y==0) return s[x][y]=='x' ? 1:0; if(dp1[x][y]!=-1) return dp1[x][y]; int ret=1000; ret=min 阅读全文
posted @ 2014-02-08 16:26 wonderzy 阅读(160) 评论(0) 推荐(0) 编辑
摘要: 该题的难点在于费用的计算,需考虑未来能转移到的所有状态用dp[l][r][next]表示l到r之间以及r之后与r同色的所有next个方块的最大费用和#include #include #include using namespace std;int t,n,a[202],k,cnt;int dp[202][202][202];struct block{ int x,c; block(){} block(int x,int c):x(x),c(c){}}b[202];void init(){ k=1,cnt=1; for(int i=1;i=r) return ne... 阅读全文
posted @ 2014-02-08 16:21 wonderzy 阅读(234) 评论(0) 推荐(0) 编辑
摘要: 我是渣渣。。。。。。。。。数组开小了,弹得蛋碎了,关键还返回wa,本地跑没崩掉,一点关闭就崩了。。。。。。。。。DP考虑每一位上的状态,即用和不用Level Upper,注意LV5是无效的即可,就酱。。。。。。。。 1 #include 2 #include 3 #include 4 using namespace std; 5 int L,n,x,y; 6 int a[110],l[110]; 7 int dp[210]; 8 int DP(int z){ 9 if(dp[z]!=-1) return dp[z];10 if(z>n) return dp[z]=0;11... 阅读全文
posted @ 2013-12-29 21:28 wonderzy 阅读(159) 评论(0) 推荐(0) 编辑
摘要: 一道裸的单调队列,每次把一个数加进单调队列,将队列头不符合要求的弹出队列,维护这个过程中的一个最大值。 1 #include 2 #include 3 using namespace std; 4 int t,n,m; 5 int a[1000010]; 6 int q[1000010]; 7 int main(){ 8 scanf("%d",&t); 9 for(int ca=1;cam) head++;20 ans=max(ans,q[tail-1]-q[head]+1+m-(q[tail-1]-q[head]-(tail-1-head)));21... 阅读全文
posted @ 2013-12-07 20:09 wonderzy 阅读(137) 评论(0) 推荐(0) 编辑
摘要: 这道题其实就是个水题,可惜我忘了一种传说中叫双指针的东西,太弱了,呜呜。 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 using namespace std; 8 int n; 9 long long a[5010],b[5010];10 int num[5010];11 template inline void readint(T& x) {12 char c;13 int mul = 1;14 while((c = getchar()) != EOF)... 阅读全文
posted @ 2013-12-04 21:39 wonderzy 阅读(217) 评论(0) 推荐(0) 编辑
摘要: Root::Problem Set Volumes (100...1999)::Volume 9 (900-999)10048 - AudiophobiaTime limit: 3.000 secondsProblem B: AudiophobiaConsider yourself lucky! Consider yourself lucky to be still breathing and having fun participating in this contest. But we apprehend that many of your descendants may not have 阅读全文
posted @ 2013-11-23 21:44 wonderzy 阅读(319) 评论(0) 推荐(0) 编辑
摘要: 最长公共子序列nlogn神算法,线段树换了几种姿势,怎么搞都超时,把他转换成LIS就AC了A : 3 3 1 1 2 2B : 3 2 3 1 2 1B中的每个元素在A中的位置倒序再放入B中可得 {2,1}{6,5}{2,1}{4,3}{6,5}{4,3}我们发现,B中的每一个大括号取一个数,对应A中的匹配加1,而要使A的标号递增,就把每个括号按递减顺序排列,然后对这个序列求LIS就是答案。 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #define maxn 200... 阅读全文
posted @ 2013-11-20 20:39 wonderzy 阅读(253) 评论(0) 推荐(0) 编辑
摘要: Alice要赢的话,只有两种情况,平和胜对于A和B,若要求相同,x与y不同,x->~y,y->~x 若要求不同,x与y相同,x->~y,y->~x 1 #include 2 #include 3 #include 4 using namespace std; 5 int t,n,m; 6 int a[10010]; 7 int f[4][2]; 8 void gao(){ 9 f[1][0]=1,f[1][1]=2;10 f[2][0]=2,f[2][1]=3;11 f[3][0]=3,f[3][1]=1;12 }13 struct edge{14 ... 阅读全文
posted @ 2013-11-13 14:19 wonderzy 阅读(158) 评论(0) 推荐(0) 编辑
摘要: 貌似人家都是用链表过的,我太弱了,只会用线段树,排最后了,还好1A了。。。。 1 #include 2 #include 3 #include 4 using namespace std; 5 int t,n; 6 int dp[100010]; 7 struct tree{ 8 int l,r; 9 int ans,lans,rans; 10 }a[400010];11 struct point{12 int v,x;13 }p[100010];14 int ans[100010];15 void build(int l,int r,int k){1... 阅读全文
posted @ 2013-11-11 18:21 wonderzy 阅读(198) 评论(0) 推荐(0) 编辑