标签:acm c++ codeforces
#include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <algorithm> #include <iostream> #include <vector> #include <queue> #include <climits> #define pb push_back using namespace std; const long long NN=4001111; long long f[2222][2222]; long long s1[4004]; long long s2[4004]; struct P{ long long v; int i,j; }sum[NN]; bool cmp(P s1,P s2){ return s1.v>s2.v; } int main(){ long long n;cin>>n; for(long long i=1;i<=n;i++) for(long long j=1;j<=n;j++){ //cin>>f[i][j]; scanf("%I64d",&f[i][j]); s1[i+j-1]+=f[i][j]; s2[n+1-j+i-1]+=f[i][j]; } for(long long i=1;i<=n;i++) for(long long j=1;j<=n;j++){ long long id=(i-1)*n+j; sum[id].v=s1[i+j-1]+s2[n+1-j+i-1]-f[i][j]; sum[id].i=i; sum[id].j=j; } long long ans1=-1,ans2=-1; long long ansx1=0,ansy1=0,ansx2=0,ansy2=0; for(long long i=1;i<=n*n;i++) { if((abs(sum[i].i+sum[i].j)&1)&&ans1<sum[i].v) { ans1=sum[i].v; ansx1=sum[i].i,ansy1=sum[i].j; } if(!(abs(sum[i].i+sum[i].j)&1) && ans2<sum[i].v) { ans2=sum[i].v; ansx2=sum[i].i,ansy2=sum[i].j; } } cout<<ans1+ans2<<endl; cout<<ansx1<<' '<<ansy1<<' '; cout<<ansx2<<' '<<ansy2<<endl; }
Codeforces 463C. Gargari and Bishops
标签:acm c++ codeforces
原文地址:http://blog.csdn.net/u013912596/article/details/38960413