"Ray, Pass me the dishes!" Time Limit: 3000MS Memory Limit: Unknown 64bit IO Format: %lld & %llu [Submit] [Go Back] [Status] Description After doing Ray a great favor to collect sticks for Ray, Poor Neal bec…
原题链接 Description After doing Ray a great favor to collect sticks for Ray, Poor Neal becomes very hungry. In returnfor Neal's help, Ray makes a great dinner for Neal. When it is time for dinner, Ray arranges all the dishes he makes in a single line (a…
又是一道线段树区间更新的题: #include<cstdio> #include<algorithm> #include<cstring> #define ll long long #define maxn 500005 using namespace std; ll sum[maxn]; struct tree { int l,r; int ml,mr; int pre,suf; tree *left,*right; } tr[maxn*]; int trcount;…
思路 线段树维护最大子段和,只不过这题还要维护左右端点 还是维护pre,suf,sum,ans,只不过每个再多出一个维护端点的变量即可 注意多解讨论的大于号和大于等于号 代码 #include <cstdio> #include <algorithm> #include <cstring> #define int long long using namespace std; const int MAXN = 500100; struct Node{ int premax…
http://acm.hdu.edu.cn/showproblem.php?pid=3938 Portal Problem Description ZLGG found a magic theory that the bigger banana the bigger banana peel .This important theory can help him make a portal in our universal. Unfortunately, making a pair of po…
用KMP里面的next数组即可,原理就是next数组的原理 #include<cstdio> #include<cstdlib> #include<algorithm> #include<cstring> #include<vector> #define MAXN 1000000+10 #define ll long long using namespace std; char s[MAXN]; int n; int nxt[MAXN]; voi…
dp 可以发现,对于(i,j),要么把它运上去,那么把它运到左边,枚举一下即可 #include<cstdio> #include<cstdlib> #include<algorithm> #include<cstring> #define MAXN 505 using namespace std; int f[MAXN][MAXN]; int a[MAXN][MAXN],b[MAXN][MAXN]; int s[MAXN][MAXN],t[MAXN][MA…