Wrong Answer.wrong answer Too short on line 1.
说我输出太短?!
高精写的太丑,见谅其实我写这题是为了调试模板
删去了一些无用模板
#include<bits/stdc++.h>
using namespace std;
/*-------------------------basic template---------------------------*/
/*--------defines & constants--------*/
#define ll long long
#define ull unsigned ll
#define Tmpl template<typename _T>
const ll MOD=/*modulo number*/998244353;
Tmpl
_T pw(_T ds,ll zs)
{
if(!zs)return 1;
_T t=pw(ds,zs>>1);t*=t;
if(zs&1)return t*ds;
return t;
}/*
/*--------Big Integer--------*/
struct BigInt
{
vector<ll>num;
/*----giving value----*/
BigInt(const ll llval=0)
{
ll temp=llval;
while(temp)num.push_back(temp%10),temp/=10;
}
BigInt operator=(const ll llval)
{
(*this)=BigInt(llval);
return *this;
}
BigInt operator=(const string strval)
{
num.clear();
for(int i=strval.size()-1;~i;--i)
num.push_back(strval[i]-'0');
return *this;
}
/*----comparing operators----*/
bool operator==(const BigInt B)const
{
if(num.size()!=B.num.size())return 0;
for(int i=num.size()-1;~i;--i)
if(num[i]!=B.num[i])return 0;
return 1;
}
bool operator<(const BigInt B)const
{
if(num.size()!=B.num.size())return num.size()<B.num.size();
for(int i=num.size()-1;~i;--i)
if(num[i]!=B.num[i])return num[i]<B.num[i];
return 0;
}
bool operator>(const BigInt B)const{return B<(*this);}
bool operator<=(const BigInt B)const{return !(B<(*this));}
bool operator>=(const BigInt B)const{return !(B<(*this));}
/*----calculating operators----*/
BigInt pop_zero(){while(!num.back())num.pop_back();return *this;}
BigInt operator+(const BigInt B)const
{
BigInt C;//result
int temp=0;
int n=max(num.size(),B.num.size());
for(int i=0;i<n;i++)
{
if(i<num.size())temp+=num[i];
if(i<B.num.size())temp+=B.num[i];
C.num.push_back(temp%10);
temp/=10;
}
if(temp)C.num.push_back(temp);
return C;
}
BigInt operator+=(const BigInt B){return (*this)=(*this)+B;}
BigInt operator-(const BigInt B)const
{
BigInt C;//result
int temp=0;
int n=max(num.size(),B.num.size());
for(int i=0;i<n;i++)
{
if(i<num.size())temp+=num[i];
if(i<B.num.size())temp+=B.num[i];
C.num.push_back((temp+10)%10);
temp=(temp>=0?0:-1);
}
C.pop_zero();
return C;
}
BigInt operator-=(const BigInt B){return (*this)=(*this)-B;}
BigInt operator*(const BigInt B)const//龟速乘,FFT乘法见Fast_Mul
{
BigInt C;
int Lena=num.size(),Lenb=B.num.size();
for(int i=0;i<=Lena+Lenb;i++)C.num.push_back(0);
for(int i=0;i<Lena;i++)
for(int j=0;j<Lenb;j++)
C.num[i+j]+=num[i]*B.num[j];
for(int i=0;i<Lena+Lenb;i++)
C.num[i+1]+=C.num[i]/10,C.num[i]%=10;
C.pop_zero();
return C;
}
BigInt operator*=(const BigInt B){return (*this)=(*this)*B;}
BigInt operator/(const BigInt B)const
{
BigInt A=*this;
if(A<B)return 0;
BigInt C;
for(int i=num.size()-B.num.size();~i;i--)
{
C.num.push_back(0);
BigInt t1,t2,p10=pw((BigInt)10,i);
t1=0;
for(int j=i;j<num.size();j++)
t1=t1*10+num[j];
t2=A-t1*p10;
while(t1>=B)C.num.back()++,t1-=B;
A=t2+t1*p10;
}
reverse(C.num.begin(),C.num.end());
C.pop_zero();
return C;
}
BigInt operator/=(const BigInt B){return (*this)=(*this)/B;}
BigInt operator%(const BigInt B)const
{
BigInt A=*this;
if(A<B)return A;
for(int i=num.size()-B.num.size();~i;i--)
{
BigInt t1,t2,p10=pw((BigInt)10,i);
t1=0;
for(int j=i;j<num.size();j++)
t1=t1*10+num[j];
t2=(*this)-t1*p10;
while(t1>=B)t1-=B;
A=t2+t1*p10;
}
A.pop_zero();
return A;
}
BigInt operator%=(const BigInt B){return (*this)=(*this)%B;}
};
istream& operator>>(istream &in,BigInt &A)
{
string str;
in>>str;
A=str;
return in;
}
ostream& operator<<(ostream &out,const BigInt A)
{
if(A==0)out<<0;
else
{
for(int i=A.num.size()-1;~i;--i)
out<<A.num[i];
}
return out;
}
const int N=85;
int n,m;
BigInt a[N],dp[N][N],ans;
void Init()
{
}
void Solve()
{
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++)cout<<a[j]<<(j==m?'\n':' ');
// for(int j=1;j<=m;j++)for(int k=j-1;k<=m;k++)dp[j][k]=0;
for(int dis=m-2;dis>=-1;dis--)
for(int j=1;j+dis<=m;j++)
{
int k=j+dis;
if(j==1&&k==m){dp[j][k]=0;continue;}
BigInt t=pw(BigInt(2),m-dis-1);
dp[j][k]=max(j>1?(t*a[j-1]+dp[j-1][k]):0\
,k<m?(t*a[k+1]+dp[j][k+1]):0);
}
BigInt ma=0;
for(int j=1;j<=m;j++)ma=max(ma,dp[j][j-1]);
// for(int j=1;j<=m;j++)
// for(int k=j-1;k<=m;k++)
// cout<<"dp["<<j<<"]["<<k<<"]="<<dp[j][k]<<endl;
cout<<endl;
ans+=ma;
}
cout<<ans;
}
void QingKong()
{
}
int main()
{
ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
int T=1;
//cin>>T;
Init();
while(T--)
//while(cin>>n&&n)
//while(cin>>n)
{
Solve();
QingKong();//多测不清空,抱灵两行泪
}
return 0;
}