用户输出
1 3
系统信息
Exited with return code 0
编号 | 题目 | 状态 | 分数 | 总时间 | 内存 | 代码 / 答案文件 | 提交者 | 提交时间 |
---|---|---|---|---|---|---|---|---|
#2469 | #1005. 兜圈子 | Accepted | 100 | 2546 ms | 35332 K | Python 3 / 637 B | t330034013 | 2023-11-18 11:21:05 |
import collections
m, n = map(int, input().split())
matrix = []
for _ in range(m):
matrix.append(list(input()))
i = 0
j = 0
record = collections.defaultdict(int)
ju = False
while i > 0 or j > 0 or i < m - 1 or j < n - 1:
record[(i, j)] += 1
if record[(i, j)] == 2:
print(-1)
break
if matrix[i][j] == 'R' and j != n - 1:
j += 1
elif matrix[i][j] == 'L' and j != 0:
j -= 1
elif matrix[i][j] == 'U' and i != 0:
i -= 1
elif matrix[i][j] == 'D' and i != m - 1:
i += 1
else:
ju = True
break
if ju:
print(i + 1, j + 1)
用户输出
1 3
系统信息
Exited with return code 0
9 44
RRDDDDRRRDDDRRRRRRDDDRDDDDRDDRDDDDDDRRDRRRRR
RRRDLRDRDLLLLRDRRLLLDDRDLLLRDDDLLLDRRLLLLLDD
DRDLR
<310 bytes omitted>
用户输出
9 5
系统信息
Exited with return code 0
500 500
RRUURUUURDRURLLLUDDRLRUUUURRRLRUUULRLURDUDUURDRRUDDRDLLLRRLLLLULRUULRRLDDRURDLULDUDDLRRRLUDR
<250408 bytes omitted>
用户输出
1 3
系统信息
Exited with return code 0
500 500
DDDUUULULDUUUUDRULURDLLULUURDLRUULDLUDRLLDDDULUURDLLDLDDRDULUUURULDRDUDUDDRDLLLLRDDUULLRLUUD
<250408 bytes omitted>
用户输出
-1
系统信息
Exited with return code 0
500 500
LULRRLLRDDULRUULRDULRUDUDLDDULRUDLLRRDULDRLDUDLDRULUUDUURLLLDRRLLDUUULUURRLRLLLDDRLDLDDRUDRD
<250408 bytes omitted>
用户输出
1 1
系统信息
Exited with return code 0
500 500
RRRDLURDUUDLRRRUURUDLUDRURURUURUDDRUDDDDURUDURULDLRRRLDRDDRDDULURDDDLRDURUDDRLUUDRLUDLLDURRL
<250408 bytes omitted>
用户输出
-1
系统信息
Exited with return code 0
500 500
RRRRRDDLDLDLRRRRDLRLLLLLRUUURRUDRURDULLDLUUDLULLDLURUDDLRLRRLLRLRUUURLURDURULLRRRDULRDLDDLUU
<250408 bytes omitted>
用户输出
-1
系统信息
Exited with return code 0
500 500
DRDULLRDDURDLLLUDULRLLRRDLDUDDUULDDURUDDURDDRLRDRDRRLURDRUDLRULDRDRDURUUUDDRDDRLRDRLRUURRRUL
<250408 bytes omitted>
用户输出
-1
系统信息
Exited with return code 0
500 500
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
<250408 bytes omitted>
用户输出
-1
系统信息
Exited with return code 0
500 500
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
<250408 bytes omitted>
用户输出
341 1
系统信息
Exited with return code 0
500 500
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
<250408 bytes omitted>
用户输出
500 432
系统信息
Exited with return code 0
500 500
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
<250408 bytes omitted>
用户输出
432 500
系统信息
Exited with return code 0