For problem statement at 0-999/700-799/730-739/733/problemD.txt this is a correct solution, but verifier at 0-999/700-799/730-739/733/verifierD.go ends with case 17 failed: expected "2\n2 1" got "2\n1 2"
input:2
12 18 10
18 4 12
exit status 1 can you fix the verifier? package main
import (
"bufio"
"fmt"
"io"
"os"
)
type Key struct {
a, b int64
}
type BestTwo struct {
h1, h2 int64
id1, id2 int
}
func update(mp map[Key]BestTwo, key Key, h int64, id int) {
v := mp[key]
if v.id1 == id {
if h > v.h1 {
v.h1 = h
}
mp[key] = v
return
}
if v.id2 == id {
if h > v.h2 {
v.h2 = h
}
if v.h2 > v.h1 {
v.h1, v.h2 = v.h2, v.h1
v.id1, v.id2 = v.id2, v.id1
}
mp[key] = v
return
}
if h > v.h1 {
v.h2, v.id2 = v.h1, v.id1
v.h1, v.id1 = h, id
} else if h > v.h2 {
v.h2, v.id2 = h, id
}
mp[key] = v
}
func main() {
data, _ := io.ReadAll(os.Stdin)
p := 0
nextInt := func() int64 {
for p < len(data) && (data[p] < '0' || data[p] > '9') {
p++
}
var v int64
for p < len(data) && data[p] >= '0' && data[p] <= '9' {
v = v*10 + int64(data[p]-'0')
p++
}
return v
}
n := int(nextInt())
mp := make(map[Key]BestTwo, 3*n)
bestVal := int64(-1)
bestK := 1
ans1, ans2 := 1, 0
for i := 1; i <= n; i++ {
x := nextInt()
y := nextInt()
z := nextInt()
if x > y {
x, y = y, x
}
if y > z {
y, z = z, y
}
if x > y {
x, y = y, x
}
if x > bestVal {
bestVal = x
bestK = 1
ans1 = i
}
update(mp, Key{y, z}, x, i)
update(mp, Key{x, z}, y, i)
update(mp, Key{x, y}, z, i)
}
for k, v := range mp {
if v.id2 == 0 {
continue
}
cand := k.a
if v.h1+v.h2 < cand {
cand = v.h1 + v.h2
}
if cand > bestVal {
bestVal = cand
bestK = 2
ans1 = v.id1
ans2 = v.id2
}
}
out := bufio.NewWriter(os.Stdout)
if bestK == 1 {
fmt.Fprintln(out, 1)
fmt.Fprintln(out, ans1)
} else {
fmt.Fprintln(out, 2)
fmt.Fprintln(out, ans1, ans2)
}
out.Flush()
}