ENG  RUSTimus Online Judge
Online Judge
Задачи
Авторы
Соревнования
О системе
Часто задаваемые вопросы
Новости сайта
Форум
Ссылки
Архив задач
Отправить на проверку
Состояние проверки
Руководство
Регистрация
Исправить данные
Рейтинг авторов
Текущее соревнование
Расписание
Прошедшие соревнования
Правила
вернуться в форум

Обсуждение задачи 1178. Дороги Акбардина

Показать все сообщения Спрятать все сообщения

(C++ VS Go) What are the tests #2 and #6? grinrag 28 сен 2020 21:49
I am learning Golang and rewriting my solutions from C++ to Golang, changes should no affect the result, but it started failing either on test #2 or test #6.

Could you, please, provide me those tests to understand what is the problem?

Thanks!

Edited by author 29.09.2020 01:07
Ok, looks like in my case the format of input data in tests #2 and #6 is differ from the one in the example. Accepted Go code is:


package main

import (
    "fmt"
    "sort"
)

type city struct {
    n, x, y int
}

func main() {
    var n int
    fmt.Scan(&n)
    m := make([]city, n)

    for i := 0; i < n; i++ {
        m[i].n = i + 1
        fmt.Scan(&m[i].x, &m[i].y)
    }

    sort.Slice(m, func(i, j int) bool {
        if m[i].x < m[j].x {
            return true
        }
        return false
    })

        for i := 0; i < n; i += 2 {
        fmt.Println(m[i].n, m[i+1].n)
    }
}


time:   0.14
memory: 2 044 КB


Edited by author 29.09.2020 01:10