結果

問題 No.1133 キムワイプイーター
ユーザー lam6er
提出日時 2025-03-20 20:15:37
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 98 ms / 2,000 ms
コード長 628 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 242 ms
コンパイル使用メモリ 96,108 KB
実行使用メモリ 86,016 KB
最終ジャッジ日時 2026-07-07 08:32:39
合計ジャッジ時間 5,391 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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