463C - Gargari and Bishops - CodeForces Solution


greedy hashing implementation *1900

Please click on ads to support us..

C++ Code:

#include <iostream>
#include <cstdio>
using namespace std;
__int64 n,t,r,a[2001][2001],v1[2001<<1],v2[2001<<1],x[]={1,2},y[]={1,1},p[2];
int main()
{
    cin>>n;
    for(int i=0;i<n;i++) for(int j=0;j<n;j++) scanf("%I64d",&a[i][j]),v1[i+j]+=a[i][j],v2[i-j+n]+=a[i][j];
    for(int i=0;i<n;i++) for(int j=0;j<n;j++){
      t=(i+j)&1;
      r=v1[i+j]-a[i][j]+v2[i-j+n];
      if(r>p[t])x[t]=i+1,y[t]=j+1,p[t]=r;
    }
    printf("%I64d\n%I64d %I64d\n%I64d %I64d",p[0]+p[1],x[0],y[0],x[1],y[1]);
    return 0;
}


Comments

Submit
0 Comments
More Questions

1669D - Colorful Stamp
1669B - Triple
1669A - Division
1669H - Maximal AND
1669E - 2-Letter Strings
483A - Counterexample
3C - Tic-tac-toe
1669F - Eating Candies
1323B - Count Subrectangles
991C - Candies
1463A - Dungeon
1671D - Insert a Progression
1671A - String Building
1671B - Consecutive Points Segment
1671C - Dolce Vita
1669G - Fall Down
4D - Mysterious Present
1316B - String Modification
1204A - BowWow and the Timetable
508B - Anton and currency you all know
1672A - Log Chopping
300A - Array
48D - Permutations
677C - Vanya and Label
1583B - Omkar and Heavenly Tree
1703C - Cypher
1511C - Yet Another Card Deck
1698A - XOR Mixup
1702E - Split Into Two Sets
1703B - ICPC Balloons