init
This commit is contained in:
commit
851751ea87
82 changed files with 2093 additions and 0 deletions
70
3L.py
Normal file
70
3L.py
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
import sys
|
||||
|
||||
data = sys.stdin.read().split()
|
||||
if not data:
|
||||
exit()
|
||||
n = int(data[0])
|
||||
m = int(data[1])
|
||||
ans = []
|
||||
for i in range(n):
|
||||
ans.extend(list(data[2 + i]))
|
||||
q = [0] * (n * m)
|
||||
head = 0
|
||||
tail = 0
|
||||
for c in range(m):
|
||||
if ans[c] == '.':
|
||||
ans[c] = '^'
|
||||
q[tail] = c
|
||||
tail += 1
|
||||
for c in range(m):
|
||||
pos = (n - 1) * m + c
|
||||
if ans[pos] == '.':
|
||||
ans[pos] = 'v'
|
||||
q[tail] = pos
|
||||
tail += 1
|
||||
for r in range(n):
|
||||
pos = r * m
|
||||
if ans[pos] == '.':
|
||||
ans[pos] = '<'
|
||||
q[tail] = pos
|
||||
tail += 1
|
||||
for r in range(n):
|
||||
pos = r * m + (m - 1)
|
||||
if ans[pos] == '.':
|
||||
ans[pos] = '>'
|
||||
q[tail] = pos
|
||||
tail += 1
|
||||
while head < tail:
|
||||
pos = q[head]
|
||||
head += 1
|
||||
r = pos // m
|
||||
c = pos % m
|
||||
if r > 0:
|
||||
npos = pos - m
|
||||
if ans[npos] == '.':
|
||||
ans[npos] = 'v'
|
||||
q[tail] = npos
|
||||
tail += 1
|
||||
if r < n - 1:
|
||||
npos = pos + m
|
||||
if ans[npos] == '.':
|
||||
ans[npos] = '^'
|
||||
q[tail] = npos
|
||||
tail += 1
|
||||
if c > 0:
|
||||
npos = pos - 1
|
||||
if ans[npos] == '.':
|
||||
ans[npos] = '>'
|
||||
q[tail] = npos
|
||||
tail += 1
|
||||
if c < m - 1:
|
||||
npos = pos + 1
|
||||
if ans[npos] == '.':
|
||||
ans[npos] = '<'
|
||||
q[tail] = npos
|
||||
tail += 1
|
||||
|
||||
out = []
|
||||
for r in range(n):
|
||||
out.append("".join(ans[r * m : (r + 1) * m]))
|
||||
print("\n".join(out))
|
||||
Loading…
Add table
Add a link
Reference in a new issue