結果

問題 No.1133 キムワイプイーター
ユーザー face4
提出日時 2020-08-02 14:45:03
言語 Java
(openjdk 23)
結果
AC  
実行時間 570 ms / 2,000 ms
コード長 1,161 bytes
コンパイル時間 2,383 ms
コンパイル使用メモリ 78,056 KB
実行使用メモリ 52,800 KB
最終ジャッジ日時 2024-07-18 13:29:24
合計ジャッジ時間 15,503 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        String s = sc.next();
        int arr[][] = new int[n+1][n+1];
        for(int i = 0; i < n+1; i++){
            for(int j = 0; j < n+1; j++){
                arr[i][j] = 1;
            }
        }
        arr[0][0] = 0;
        int i = 0, j = 0;
        for(int x = 0; x < m; x++){
            switch(s.charAt(x)){
                case 'R':
                    j++;
                    break;
                case 'L':
                    j--;
                    break;
                case 'U':
                    i++;
                    break;
                case 'D':
                    i--;
                    break;
            }
            arr[i][j] = 0;
        }
        for(int k = n; k >= 0; k--){
            for(int l = 0; l <= n; l++){
                if(l > 0)   System.out.print(" ");
                System.out.print(arr[k][l]);
            }
            System.out.println();
        }
    }
}
0