Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

哇,一ac了,我转换成一维来做的

Posted by TSERROF at 2012-10-22 15:18:47 on Problem 1050
#include<iostream>
#include <cstring>
using namespace std;
int matrix[105][105],dp[105][105],len[105];//表情前i行j列的最大矩阵的和
#define INF -9999999;
int main()
{
	int n;
	while(cin>>n)
	{
		for(int i=0;i<n;++i)
			for(int j=0;j<n;++j)
				cin>>matrix[i][j];
		int sum=0,maxsum=0;
		for(int s=0;s<n-1;++s)
		{
			for(int h=1;h<=n;++h)
			{
				fill(len,len+105,0);
				for(int j=0;j<n;++j)
				{
					for(int i=s;i<h+s;++i)
					{
						len[j]+=matrix[i][j];
					}		
				}
				sum=0;
				for(int k=0;k<n;++k)
				{
					sum+=len[k];
					if(sum>maxsum)maxsum=sum;
					if(sum<0)sum=0;
				}
			}
		}	
		cout<<maxsum<<endl;
	}
	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator