package main import . "fmt" func main() { var n, m int var s string Scan(&n,&m,&s) f:=make([][]int,n) for i:=range f { f[i] = make([]int,n) } var x, y int for _, c :=range s { switch c { case 'U': y++ case 'R': x++ case 'L': x-- case 'D': y-- } f[y][x] = 1 } for _, row := range f { for i, v := range row { if i > 0 { Print(" ") } Print(1-v) } Println() } }