-
Notifications
You must be signed in to change notification settings - Fork 0
/
debug.go
64 lines (52 loc) · 884 Bytes
/
debug.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
//go:build !notdebug
package main
import (
"bufio"
"fmt"
"os"
)
type IO struct {
r *bufio.Reader
w *bufio.Writer
}
func (io *IO) nextByte() byte {
tmp, _ := io.r.ReadByte()
return tmp
}
func main() {
f, _ := os.Open("input.txt")
io := IO{
w: bufio.NewWriter(os.Stdout),
r: bufio.NewReader(f),
}
solve(&io)
}
func (io *IO) PrintNewLine() {
fmt.Fprintln(io.w)
io.Flush()
}
func (io *IO) PrintChar(b byte) {
fmt.Fprint(io.w, string([]byte{b}))
io.Flush()
}
func (io *IO) Print(x ...any) {
for i := 0; i < len(x); i++ {
switch x[i].(type) {
case []byte:
x[i] = string(x[i].([]byte))
}
}
fmt.Fprint(io.w, x...)
io.Flush()
}
func (io *IO) Println(x ...any) {
for i := 0; i < len(x); i++ {
switch x[i].(type) {
case []byte:
x[i] = string(x[i].([]byte))
}
}
fmt.Fprintln(io.w, x...)
io.Flush()
}
func (io *IO) Flush() { io.w.Flush() }