結果

問題 No.3069 Torn Documents
ユーザー maspymaspy
提出日時 2020-04-01 23:10:24
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 887 bytes
コンパイル時間 96 ms
コンパイル使用メモリ 10,896 KB
実行使用メモリ 10,788 KB
最終ジャッジ日時 2023-09-29 02:55:02
合計ジャッジ時間 3,972 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 56 ms
10,672 KB
testcase_01 WA -
testcase_02 AC 16 ms
8,204 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 16 ms
8,268 KB
testcase_08 WA -
testcase_09 AC 16 ms
8,100 KB
testcase_10 AC 17 ms
8,308 KB
testcase_11 WA -
testcase_12 AC 17 ms
8,096 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 16 ms
8,156 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 17 ms
8,268 KB
testcase_21 AC 17 ms
8,140 KB
testcase_22 WA -
testcase_23 AC 17 ms
7,848 KB
testcase_24 AC 16 ms
8,100 KB
testcase_25 AC 16 ms
8,300 KB
testcase_26 AC 17 ms
8,208 KB
testcase_27 AC 17 ms
8,136 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/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)
0