#include<cstdio>
#include<cstring>
#include<unistd.h>
//#include<windows.h>
#include<map>
#include<vector>
#include<queue>
#include<stdlib.h>
#include<cmath>
#include<string>
#include <iostream>
#include<cstdlib>
#include<iomanip>
#include<fstream>
#include<complex>
#include<algorithm>//Let's include!
using namespace std;
void s2BIG(string s,int a[])
{
a[0]=s.size();
for(int i=1;i<=a[0];i++)
{
a[i]=s[a[0]-i]-'0';
}
}
void printBIG(int a[])
{
for(int i=a[0];i>=1;i--)
{
//printf("%d",a[i]);
cout<<a[i];
}
}
void i2BIG(long long a,int b[])
{
b[0]=0;
while(a>0)
{
b[0]++;
b[b[0]]=a%10;
a/=10;
}
if(b[0]==0) b[0]=1;
}
void plusBIG(int a[],int b[],int c[])
{
c[0]=max(a[0],b[0]);
int u=0;
for(int i=1;i<=c[0];i++)
{
c[i]=a[i]+b[i]+u;
u=c[i]/10;
c[i]%=10;
}
if(u>0)
{
c[0]++;
c[c[0]]=u;
}
}
void minusBIG(int a[],int b[],int c[])
{
int u=0;
c[0]=a[0];
for(int i=1;i<=a[0];i++)
{
c[i]=a[i]-b[i]-u;
u=0;
if(c[i]<0)
{
c[i]+=10;
u++;
}
}
while(c[c[0]]==0 && c[0]>1) c[0]--;
}
bool cmpBIG(int a[],int b[])
{
if(a[0]!=b[0]) return a[0]<b[0];
for(int i=a[0];i>=1;i--)
if(a[i]!=b[i]) return a[i]<b[i];
return false;
}
bool sameBIG(int a[],int b[])
{
if(a[0]!=b[0]) return a[0]<b[0];
for(int i=a[0];i>=1;i--)
if(a[i]!=b[i]) return false;
return true;
}
void mulBIG(int a[],long long b,int c[])
{
c[0]=a[0];
int u=0;
for(int i=1;i<=a[0];i++)
{
long long t=a[i]*b+u;
c[i]=t%10;
u=t/10;
}
while(u>0)
{
c[0]++;
c[c[0]]=u%10;
u/=10;
}
}
long long divBIG(int a[],long long b,int c[])
{
c[0]=a[0];
long long r=0;
for(int i=a[0];i>=1;i--)
{
long long t=r*10+a[i];
r=t%b;
c[i]=t/b;
}
while(c[c[0]]==0 && c[0]>1) c[0]--;
return r;
}
long long BIG2i(int a[])
{
long long x=0;
for(int i=a[0];i>=1;i--)
{
x=10*x+a[i];
}
return x;
}
const int ARRAY_LEN=1005;
struct huge
{
int a[ARRAY_LEN];
void clear()
{
for(int i=a[0]+1;i<ARRAY_LEN;i++)
a[i]=0;
}
void clear(int i,int j)
{
for(int z=i;z<=j&&z<ARRAY_LEN;z++)
a[z]=0;
}
void in()
{
string s;
cin>>s;
s2BIG(s,a);
}
void set(long long x)
{
clear(1,a[0]);
i2BIG(x,a);
}
void set(string s)
{
clear(1,a[0]);
s2BIG(s,a);
}
void out()
{
printBIG(a);
}
long long value()
{
return BIG2i(a);
}
huge(){set("0");}
huge(long long x){set(x);}
huge(int x){set(x);}
};
bool operator <(huge x,huge y)
{
return cmpBIG(x.a,y.a);
}
bool operator >(huge x,huge y)
{
return cmpBIG(y.a,x.a);
}
huge operator +(huge x,huge y)
{
huge z;
plusBIG(x.a,y.a,z.a);
return z;
}
huge operator -(huge x,huge y)
{
huge z;
minusBIG(x.a,y.a,z.a);
return z;
}
huge operator *(huge x,long long y)
{
huge z;
mulBIG(x.a,y,z.a);
return z;
}
huge operator *(long long y,huge x)
{
huge z;
mulBIG(x.a,y,z.a);
return z;
}
huge operator /(huge x,long long y)
{
huge z;
divBIG(x.a,y,z.a);
return z;
}
long long operator %(huge x,long long y)
{
huge z;
return divBIG(x.a,y,z.a);
}
bool operator >=(huge x,huge y)
{
return !(x<y);
}
bool operator <=(huge x,huge y)
{
return !(x>y);
}
bool operator ==(huge x,huge y)
{
return sameBIG(x.a,y.a);
}
bool operator !=(huge x,huge y)
{
return !(x==y);
}
huge two[85]={1};
int a[85];
huge f[85][85];
huge ans;
int n,m;
huge dp(int l,int r,int i)
{
if(f[l][r].a[0]!=0) return f[l][r];
if(l>r) return 0;
huge ret=/*dp(l+1,r,i+1)+a[l]*two[i]*/2*(dp(l+1,r,i+1)+a[l]),reu=/*dp(l,r-1,i+1)+a[r]*two[i]*/2*(dp(l,r-1,i+1)+a[r]);
if(ret>reu) return f[l][r]=ret;
else return f[l][r]=reu;
}
int main()
{
std::ios::sync_with_stdio(false);
for(int i=1;i<=m;i++)
two[i]=two[i-1]*2;
cin>>n>>m;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
cin>>a[j];
for(int j=1;j<=m;j++)
for(int k=1;k<=m;k++)
f[j][k].set("");//这是个0位数,0是1位数
ans=ans+dp(1,m,1);
}
ans.out();
return 0;
}
这段代码一会50分,一会60分,一会40分,一会30分,是哪里的问题呢QAQ
可能是栈空间的问题