https://codeforces.com/problemset/problem/463/C
思路:类似八皇后,每一条左对角线和右对角线有统一的标识符
左往上的:i+j
右往下的:i-j+n
#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#include<algorithm>
#define debug(a) cout<<#a<<"="<<a<<endl;
using namespace std;
const int maxn=2e3+100;
typedef long long LL;
inline LL read(){LL x=0,f=1;char ch=getchar(); while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
return x*f;}
LL a[maxn][maxn];
LL l[maxn*2],r[maxn*2];
int main(void){
cin.tie(0);std::ios::sync_with_stdio(false);
LL n;cin>>n;
for(LL i=1;i<=n;i++){
for(LL j=1;j<=n;j++){
cin>>a[i][j];
l[i-j+n]+=a[i][j];
r[i+j]+=a[i][j];
}
}
LL maxv1=-1;LL maxv2=-1;
LL x1=0;LL y1=0;LL x2=0;LL y2=0;
for(LL i=1;i<=n;i++){
for(LL j=1;j<=n;j++){
if((i+j)%2==0){
if(maxv1<l[i-j+n]+r[i+j]-a[i][j]){
maxv1=l[i-j+n]+r[i+j]-a[i][j];
x1=i;y1=j;
}
}
else if((i+j)&1){
if(maxv2<l[i-j+n]+r[i+j]-a[i][j]){
maxv2=l[i-j+n]+r[i+j]-a[i][j];
x2=i;y2=j;
}
}
}
}
cout<<maxv1+maxv2<<"\n";
cout<<x1<<" "<<y1<<" "<<x2<<" "<<y2<<"\n";
return 0;
}