結果

問題 No.1133 キムワイプイーター
ユーザー lam6er
提出日時 2025-03-20 18:39:37
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 90 ms / 2,000 ms
コード長 628 bytes
コンパイル時間 146 ms
コンパイル使用メモリ 82,168 KB
実行使用メモリ 78,080 KB
最終ジャッジ日時 2025-03-20 18:39:41
合計ジャッジ時間 3,888 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

n, m = map(int, input().split())
s = input().strip()

# Initialize grid with all 1s except (0,0)
grid = [[1] * (n + 1) for _ in range(n + 1)]
grid[0][0] = 0

x, y = 0, 0  # Starting position

for move in s:
    # Update position based on the move
    if move == 'U':
        y += 1
    elif move == 'D':
        y -= 1
    elif move == 'R':
        x += 1
    elif move == 'L':
        x -= 1
    
    # Check and consume the Kimwipe at the new position
    if grid[y][x] == 1:
        grid[y][x] = 0

# Output the grid from top (y=n) to bottom (y=0)
for y_coord in range(n, -1, -1):
    print(' '.join(map(str, grid[y_coord])))
0