forked from EndlessCheng/codeforces-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
463C.go
38 lines (35 loc) · 748 Bytes
/
463C.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package main
import (
"bufio"
. "fmt"
"io"
)
// github.com/EndlessCheng/codeforces-go
func CF463C(_r io.Reader, out io.Writer) {
in := bufio.NewReader(_r)
var n int
Fscan(in, &n)
a := make([][]int, n)
b := make([]int64, n*2)
c := make([]int64, n*2)
for i := range a {
a[i] = make([]int, n)
for j := range a[i] {
Fscan(in, &a[i][j])
b[i-j+n] += int64(a[i][j])
c[i+j] += int64(a[i][j])
}
}
mx := [2]int64{-1, -1}
p := [2][2]int{}
for i, r := range a {
for j, v := range r {
if s, k := b[i-j+n]+c[i+j]-int64(v), (i+j)&1; s > mx[k] {
mx[k], p[k] = s, [2]int{i, j}
}
}
}
Fprintln(out, mx[0]+mx[1])
Fprintln(out, p[0][0]+1, p[0][1]+1, p[1][0]+1, p[1][1]+1)
}
//func main() { CF463C(os.Stdin, os.Stdout) }