結果
| 問題 |
No.8069 Torn Documents
|
| コンテスト | |
| ユーザー |
maspy
|
| 提出日時 | 2020-04-01 23:10:24 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 887 bytes |
| コンパイル時間 | 180 ms |
| コンパイル使用メモリ | 12,800 KB |
| 実行使用メモリ | 13,312 KB |
| 最終ジャッジ日時 | 2024-07-21 21:40:09 |
| 合計ジャッジ時間 | 4,147 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 14 WA * 14 |
ソースコード
#!/usr/bin/ python3.8
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
A, B = map(int, readline().split())
S = readline().rstrip().decode()
wall = set()
path = set()
path.add((A, B))
H = A
W = B
for s in S:
if s == 'R':
if (A, B + 1) not in path:
wall.add((A, B + 1))
else:
B += 1
elif s == 'L':
if (A, B - 1) in wall or B == 0:
continue
B -= 1
path.add((A, B))
elif s == 'U':
if (A - 1, B) in wall or A == 0:
continue
A -= 1
path.add((A, B))
elif s == 'D':
if (A + 1, B) not in path:
wall.add((A + 1, B))
if (A,B) != (0, 0):
print(-1)
exit()
wall = [(x, y) for x, y in wall if 0 <= x <= H and 0 <= y <= W]
print(len(wall))
for x, y in wall:
print(x, y)
maspy