forked from EndlessCheng/codeforces-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1023E.go
66 lines (58 loc) · 1 KB
/
1023E.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
package main
import (
. "fmt"
"strings"
)
type (
input23 struct{ n int }
req23 struct{ sx, sy, tx, ty int }
resp23 struct{ s string }
guess23 struct{ ans string }
)
// github.com/EndlessCheng/codeforces-go
func CF1023E(in input23, Q func(req23) resp23) (gs guess23) {
q := func(sx, sy, tx, ty int) bool { return Q(req23{sx, sy, tx, ty}).s[0] == 'Y' }
n := in.n
ans, t := "", ""
defer func() { gs.ans = ans }()
x0, y0 := 1, 1
for x0+y0 <= n {
if q(x0+1, y0, n, n) {
x0++
ans += "D"
} else {
y0++
ans += "R"
}
}
x, y := n, n
for y > y0 {
if q(1, 1, x, y-1) {
y--
t += "R"
} else {
x--
t += "D"
}
}
ans += strings.Repeat("D", x-x0)
for i := len(t) - 1; i >= 0; i-- {
ans += string(t[i])
}
return
}
func ioq23() {
// Interaction
Q := func(req req23) (resp resp23) {
Println("?", req.sx, req.sy, req.tx, req.ty)
Scan(&resp.s)
return
}
// Input
d := input23{}
Scan(&d.n)
// Output
gs := CF1023E(d, Q)
Println("!", gs.ans)
}
//func main() { ioq23() }