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

there are 4 ways of partitioning in total, but i only find 3 in your code

Posted by 00448264 at 2005-06-04 13:15:10 on Problem 2444
In Reply To:Re:i think perhaps you have missed some cases Posted by:Windows2k at 2005-06-04 12:55:06
> #include <cstring>
> #include <cstdio>
> using namespace std;
> #define _int64 long long int
> _int64 a[501][501],b[501][501];
> _int64 abs(_int64 a) { return (a>0) ? a : -a; }
> int m,n;
> int main()
> {
> 	while(scanf("%d %d",&m,&n)==2) {
> 		if(!m&&!n) break;
> 		_int64 min=(_int64)65535*500*500;
> 		for(int i=1;i<=m;i++)
> 			for(int j=1;j<=n;j++) scanf("%lld",&a[i][j]);
> 		for(int i=1;i<=m;i++)
> 			for(int j=1;j<=n;j++) b[i][j]=b[i-1][j]+b[i][j-1]-b[i-1][j-1]+a[i][j];
> 		for(int i=1;i<m;i++)
> 			for(int j=1;j<n;j++) {
> 				_int64 x=b[i][j],y=b[m][j]-b[i][j],
> 				    z=b[m][n]-b[m][j];
> 				_int64 t=abs(x-y)+abs(y-z)+abs(z-x);
> 				if(t<min) min=t;
> 				/*x=b[i][j],y=b[m][n]-b[m][j],z=b[m][j]-b[i][j];
> 				t=abs(x-y)+abs(y-z)+abs(z-x);
> 				if(t<min) min=t;*/
> 			}
> 		for(int i=1;i<m-1;i++)
> 			for(int j=i+1;j<m;j++) {
> 				_int64 x=b[i][n],y=b[j][n]-b[i][n],z=b[m][n]-b[j][n];
> 				_int64 t=abs(x-y)+abs(y-z)+abs(z-x);
> 				if(t<min) min=t;
> 			}
> 		for(int i=1;i<n-1;i++)
> 			for(int j=i+1;j<n;j++) {
> 				_int64 x=b[m][i],y=b[m][j]-b[m][i],z=b[m][n]-b[m][j];
> 				_int64 t=abs(x-y)+abs(y-z)+abs(z-x);
> 				if(t<min) min=t;
> 			}
> 		printf("%lld\n",min);
> 	}
> }
> --
> Still GET WA :(

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