?
?题意:选两个点,这两个点的贡献为他们对角线和反对角线的数字总和。
题解:贪心,容易发现i+j分奇偶讨论能把两个对角线错开。
#include<iostream>
#include<cstdio>
#include<map>
#include<algorithm>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<cstring>
#include<vector>
#include<set>
#include<cmath>
#include<cstring>
#include<cstdlib>
#define fi first
#define se second
#define u1 (u<<1)
#define u2 (u<<1|1)
#define PII pair<int,int>
#define ll long long
#define ull unsigned long long
#define PLL pair<long long,long long>
#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define scl(a) scanf("%lld",&a)
#define rep(i,n) for(int i = 0; (i)<(n); i++)
#define rep1(i,n) for(int i = 1; (i)<=(n); i++)
#define pb(a) push_back(a)
#define mst(a,b) memset(a, b, sizeof a)
#define ac cout<<ans<<endl
using namespace std;
const int N=2020;
ll g[N][N];
ll l[3*N],r[N*3];
ll n;
void solve()
{
scl(n);
ll m1=0,m2=0;
ll x1,x2,y1,y2;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
{
scl(g[i][j]);
r[i+j]+=g[i][j];
l[i-j+n]+=g[i][j];
}
}
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
{
if((i+j)%2){
if(r[i+j]+l[i-j+n]-g[i][j]>=m1){
m1=r[i+j]+l[i-j+n]-g[i][j];
x1=i;y1=j;
}
}
else{
if(r[i+j]+l[i-j+n]-g[i][j]>=m2){
m2=r[i+j]+l[i-j+n]-g[i][j];
x2=i;y2=j;
}
}
}
}
cout<<m1+m2<<endl;
cout<<x1<<' '<<y1<<' '<<x2<<' '<<y2<<endl;
return;
}
int main()
{
//init();
int t=1;
//scd(t);
while(t--) solve();
return 0;
}
|