-
-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathtask.go
77 lines (60 loc) · 1.27 KB
/
task.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package main
import (
"bufio"
"fmt"
"os"
"strconv"
"strings"
)
func main() {
input, err := getInputData()
if err != nil {
showError(err)
}
var n, s int
input.Scan()
n, err = strconv.Atoi(input.Text())
if err != nil {
showError(err)
}
input.Scan()
s, err = strconv.Atoi(input.Text())
if err != nil {
showError(err)
}
input.Scan()
arr := strings.Fields(strings.TrimSpace(input.Text()))
res := solution(n, s, arr)
for i := 0; i < len(res); i++ {
fmt.Println(strings.Join(res[i], " "))
}
}
func solution(n, s int, arr []string) (result [][]string) {
return
}
// getInputData подготовка входных данных
func getInputData() (scan *bufio.Scanner, err error) {
var input *os.File
const maxCapacity = 1024 * 1024 * 10
input, err = getInputFromFile()
if err != nil {
showError(err)
}
scanner := bufio.NewScanner(input)
buf := make([]byte, maxCapacity)
scanner.Buffer(buf, maxCapacity)
scanner.Split(bufio.ScanLines)
return scanner, nil
}
// getInputFromFile получение ввода из файла
func getInputFromFile() (*os.File, error) {
file, err := os.Open("input.txt")
if err != nil {
return nil, err
}
return file, nil
}
// showError вывод ошибки
func showError(err interface{}) {
panic(err)
}