█████████ ████ ███░░░░░███ ░░███ ███ ░░░ ██████ ███████ ██████ ██████ ░███ ███░░███ ███░░███ ███░░███ ███░░███ ░███ ░███ ░███░███ ░███ ░███████ ░███ ░███ ░░███ ███░███ ░███░███ ░███ ░███░░░ ░███ ░███ ░░█████████ ░░██████ ░░████████░░██████ ░░██████ ░░░░░░░░░ ░░░░░░ ░░░░░░░░ ░░░░░░ ░░░░░░

Envío 5022

Problema 0xe1 - Cuadrado mágico

  • Autor: cams2692
  • Fecha: 2021-10-06 21:04:23 UTC (Hace más de 2 años)
Caso # Resultado Tiempo Memoria
#1
Error de compilación
                      # command-line-arguments
./main.go:6:2: imported and not used: "log"

                    
#2
Error de compilación
                      # command-line-arguments
./main.go:6:2: imported and not used: "log"

                    
#3
Error de compilación
                      # command-line-arguments
./main.go:6:2: imported and not used: "log"

                    
#4
Error de compilación
                      # command-line-arguments
./main.go:6:2: imported and not used: "log"

                    
#5
Error de compilación
                      # command-line-arguments
./main.go:6:2: imported and not used: "log"

                    
#6
Error de compilación
                      # command-line-arguments
./main.go:6:2: imported and not used: "log"

                    
#7
Error de compilación
                      # command-line-arguments
./main.go:6:2: imported and not used: "log"

                    
#8
Error de compilación
                      # command-line-arguments
./main.go:6:2: imported and not used: "log"

                    
#9
Error de compilación
                      # command-line-arguments
./main.go:6:2: imported and not used: "log"

                    
#10
Error de compilación
                      # command-line-arguments
./main.go:6:2: imported and not used: "log"

                    
#11
Error de compilación
                      # command-line-arguments
./main.go:6:2: imported and not used: "log"

                    
#12
Error de compilación
                      # command-line-arguments
./main.go:6:2: imported and not used: "log"

                    
#13
Error de compilación
                      # command-line-arguments
./main.go:6:2: imported and not used: "log"

                    
#14
Error de compilación
                      # command-line-arguments
./main.go:6:2: imported and not used: "log"

                    
#15
Error de compilación
                      # command-line-arguments
./main.go:6:2: imported and not used: "log"

                    
#16
Error de compilación
                      # command-line-arguments
./main.go:6:2: imported and not used: "log"

                    
#17
Error de compilación
                      # command-line-arguments
./main.go:6:2: imported and not used: "log"

                    
#18
Error de compilación
                      # command-line-arguments
./main.go:6:2: imported and not used: "log"

                    
#19
Error de compilación
                      # command-line-arguments
./main.go:6:2: imported and not used: "log"

                    
#20
Error de compilación
                      # command-line-arguments
./main.go:6:2: imported and not used: "log"

                    
Puntos totales: 0 / 100

Código

package main

import (
	"bufio"
	"fmt"
	"log"
	"os"
	"strconv"
	"strings"
)

func main() {
	reader := bufio.NewReader(os.Stdin)

	n, _ := reader.ReadString('\n')
	n = strings.ReplaceAll(n, "\n", "")
	nInt, _ := strconv.ParseInt(n, 10, 64)
	var diagonal1 int64 = 0
	var diagonal2 int64 = 0
	var sumValue int64 = 0
	isInit := true
	for i := 0; i < int(nInt); i++ {
		row, _ := reader.ReadString('\n')
		row = strings.ReplaceAll(row, "\n", "")
		rowSplits := strings.Split(row, " ")
		var rowSum int64 = 0
		for index, v := range rowSplits {
			vInt, _ := strconv.ParseInt(v, 10, 64)

			if index == i {
				diagonal1 += vInt
			}
			if int(nInt-1)-i == index {
				diagonal2 += vInt
			}
			rowSum += vInt

		}
		if isInit {
			sumValue = rowSum
			isInit = false
		}

		if sumValue != rowSum {
			fmt.Println("No")
			return
		}

	}

	if sumValue != diagonal1 || sumValue != diagonal2 {

		fmt.Println("No")
		return
	}

	fmt.Println("Yes")

}