結果

問題 No.8069 Torn Documents
ユーザー titia
提出日時 2020-04-01 23:12:35
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 589 bytes
コンパイル時間 217 ms
コンパイル使用メモリ 12,288 KB
実行使用メモリ 12,928 KB
最終ジャッジ日時 2024-07-21 21:40:23
合計ジャッジ時間 5,259 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 7 WA * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

A,B=map(int,input().split())
S=input()

NOW=[A,B]
USED=set()
USED.add((A,B))
ANS=[]

for s in S:
    if s=="L" and NOW[1]!=0:
        NOW[1]-=1
        USED.add(tuple(NOW))
    elif s=="U" and NOW[0]!=0:
        NOW[0]-=1
        USED.add(tuple(NOW))
    elif s=="R":
        x,y=NOW
        if (x,y+1) in USED:
            NOW=[x,y+1]
        else:
            ANS.append((x,y+1))

    elif s=="D":
        x,y=NOW
        if (x+1,y) in USED:
            NOW=[x+1,y]
        else:
            ANS.append((x+1,y))

print(len(ANS))
for x,y in ANS:
    print(x,y)
        
        
        
0