結果
問題 |
No.1133 キムワイプイーター
|
ユーザー |
|
提出日時 | 2023-11-07 21:55:38 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 484 ms / 2,000 ms |
コード長 | 1,252 bytes |
コンパイル時間 | 2,932 ms |
コンパイル使用メモリ | 82,396 KB |
実行使用メモリ | 51,772 KB |
最終ジャッジ日時 | 2024-09-25 23:28:49 |
合計ジャッジ時間 | 13,960 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 31 |
ソースコード
import java.util.*; import java.lang.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); char[] s = sc.next().toCharArray(); int[][] kimwipes = new int[n+1][n+1]; for(int i = 0 ; i <= n ; i++){ Arrays.fill(kimwipes[i] , 1); } int x = 0; int y = 0; kimwipes[0][0] = 0; for(int i = 0 ; i < s.length ; i++){ char c = s[i]; if(c == 'U' && y < n){ kimwipes[y+1][x] = 0; y++; }else if(c == 'D' && y > 0){ kimwipes[y-1][x] = 0; y--; }else if(c == 'R' && x < n){ kimwipes[y][x+1] = 0; x++; }else if(c == 'L' && x > 0){ kimwipes[y][x-1] = 0; x--; } } for(int i = n ; i >= 0 ; i--){ for(int j = 0 ; j <= n ; j++){ System.out.print(kimwipes[i][j]+" "); } System.out.println(); } } }