← Home
For problem statement at 0-999/600-699/650-659/659/problemB.txt this is a correct solution, but verifier at 0-999/600-699/650-659/659/verifierB.go ends with test 68 failed
input:
11 4
name1 1 165
name10 4 445
name11 4 86
name2 1 205
name3 2 532
name4 2 679
name5 3 687
name6 3 687
name7 4 155
name8 4 46
name9 1 493
expected:
name9 name2
name4 name3
name6 name5
name10 name7
got:
name9 name2
name4 name3
name5 name6
name10 name7

exit status 1 can you fix the verifier? package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

type Participant struct {
	name  string
	score int
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	if !scanner.Scan() {
		return
	}
	n, _ := strconv.Atoi(scanner.Text())
	scanner.Scan()
	m, _ := strconv.Atoi(scanner.Text())

	regions := make([][]Participant, m+1)
	for i := 0; i < n; i++ {
		scanner.Scan()
		name := scanner.Text()
		scanner.Scan()
		region, _ := strconv.Atoi(scanner.Text())
		scanner.Scan()
		score, _ := strconv.Atoi(scanner.Text())

		regions[region] = append(regions[region], Participant{name, score})
	}

	out := bufio.NewWriter(os.Stdout)
	for i := 1; i <= m; i++ {
		sort.Slice(regions[i], func(a, b int) bool {
			return regions[i][a].score > regions[i][b].score
		})

		if len(regions[i]) > 2 && regions[i][1].score == regions[i][2].score {
			fmt.Fprintln(out, "?")
		} else {
			fmt.Fprintln(out, regions[i][0].name, regions[i][1].name)
		}
	}
	out.Flush()
}