Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- n = int(input())
- s = input()
- c = n+1
- l = [0]*n
- if n == 0:
- print('ERROR 1')
- quit()
- for i in range(n):
- l[i] = list(range(c-n, c))
- c += n
- l[-1][-1] = k = 0
- t = [n-1,n-1]
- p = [n-1,n-1]
- for i in s:
- k += 1
- if i == 'U':
- t[0] -= 1
- elif i == 'D':
- t[0] += 1
- elif i == 'R':
- t[1] += 1
- elif i == 'L':
- t[1] -= 1
- h = [n,-1]
- if t[1] in h or t[0] in h:
- print('ERROR', k)
- quit()
- l[p[0]][p[1]], l[t[0]][t[1]] = l[t[0]][t[1]], l[p[0]][p[1]]
- p.clear()
- p = list(t)
- for i in l:
- print(*i)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement