結果

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

ソースコード

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))

if NOW!=[0,0]:
    print(-1)
else:
    print(len(ANS))
    for x,y in ANS:
        print(x,y)
        
        
        
0