結果
| 問題 |
No.8069 Torn Documents
|
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2020-04-01 23:25:11 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 814 bytes |
| コンパイル時間 | 96 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 13,312 KB |
| 最終ジャッジ日時 | 2024-07-21 21:41:09 |
| 合計ジャッジ時間 | 4,091 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 8 WA * 20 |
ソースコード
import sys
input = sys.stdin.readline
A,B=map(int,input().split())
S=input().strip()
NOW=[A,B]
USED=set()
USED.add((A,B))
ANS=[]
for s in S:
x,y=NOW
if 0<=x<=A and 0<=y<=B:
True
else:
print(-1)
sys.exit()
if s=="L":
NOW[1]-=1
USED.add(tuple(NOW))
elif s=="U":
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))
for x,y in USED:
if 0<=x<=A and 0<=y<=B:
True
else:
print(-1)
sys.exit()
print(len(ANS))
for x,y in ANS:
print(x,y)
titia