-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy path10800.go
63 lines (57 loc) · 1.04 KB
/
10800.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
// UVa 10800 - Not That Kind of Graph
package main
import (
"fmt"
"io"
"os"
"strings"
)
const (
max = 102
mid = 52
)
func solve(out io.Writer, line string) {
graph := make([][]byte, max)
for i := range graph {
graph[i] = []byte(strings.Repeat(" ", mid))
}
currX, currY := 0, mid-1
minY, maxY := mid-1, mid-1
for i := range line {
if currY < minY {
minY = currY
}
if currY > maxY {
maxY = currY
}
switch line[i] {
case 'R':
graph[currY][currX] = '/'
currY--
case 'F':
currY++
graph[currY][currX] = '\\'
default:
graph[currY][currX] = '_'
}
currX++
}
for i := minY; i <= maxY; i++ {
fmt.Fprintln(out, "| "+strings.TrimRight(string(graph[i]), " "))
}
fmt.Fprintln(out, "+-"+strings.Repeat("-", currX+1))
}
func main() {
in, _ := os.Open("10800.in")
defer in.Close()
out, _ := os.Create("10800.out")
defer out.Close()
var n int
var line string
fmt.Fscanf(in, "%d", &n)
for kase := 1; kase <= n; kase++ {
fmt.Fscanf(in, "%s", &line)
fmt.Fprintf(out, "Case #%d:\n", kase)
solve(out, line)
}
}