简单的模拟题。
暴力枚举
/*
模拟
*/
#include<algorithm>
#include<iostream>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#include<math.h>
#include<queue>
#include<stack>
#include<map>
#include<set>
using namespace std;
typedef long long int64;
//typedef __int64 int64;
typedef pair<int64,int64> PII;
#define MP(a,b) make_pair((a),(b))
const int inf = 0x3f3f3f3f;
const double pi=acos(-1.0);
const int dx[]={,-,,};
const int dy[]={,,,-};
const double eps = 1e-;
const int maxm = ;
const int maxn = ; int num[ maxn ][ maxn ]; int main(){
//freopen( "in.txt","r",stdin );
int n;
while( scanf("%d",&n),n ){
memset( num,,sizeof( num ) );
for( int i=;i<=n;i++ )
for( int j=;j<=n;j++ )
scanf("%d",&num[i][j]);
int cnt = ;
int sum = ;
int CNT = n;
for( int loop=;loop<=(n/);loop++ ){
//int x = loop;
//int y = loop;
//printf("loop = %d\n",loop);
int lux = loop,luy = loop;
int ldx = loop+CNT-,ldy = loop;
int rux = loop,ruy = loop+CNT-;
int rdx = loop+CNT-,rdy = loop+CNT-;
int ti = CNT - ;
int cc = ;
int temp_sum = ;
int temp_cnt = ;
//bool f = false;
while( cc<ti ){
int temp = ;
//if( f==false ){
// f = true;
// ti -- ;
//}
//printf("(%d,%d) (%d,%d) (%d,%d) (%d,%d)\n",lux,luy,rux,ruy,ldx,ldy,rdx,rdy);
temp = num[lux][luy] + num[rux][ruy] + num[ldx][ldy] + num[rdx][rdy];
if( temp>temp_sum ){
temp_sum = temp;
temp_cnt = min( cc,ti-cc );
}
else if( temp==temp_sum ){
temp_cnt = min( temp_cnt,min( cc,ti-cc ) );
}
cc ++ ;
luy ++ ;
rux ++ ;
rdy -- ;
ldx -- ;
}
CNT -= ;
sum += temp_sum;
cnt += temp_cnt;
}
printf("%d %d\n",sum+num[(n/)+][(n/)+],cnt);
}
return ;
}