結果

問題 No.1133 キムワイプイーター
ユーザー RISE70226821RISE70226821
提出日時 2020-08-03 17:27:01
言語 Java21
(openjdk 21)
結果
AC  
実行時間 910 ms / 2,000 ms
コード長 995 bytes
コンパイル時間 2,740 ms
コンパイル使用メモリ 75,768 KB
実行使用メモリ 130,504 KB
最終ジャッジ日時 2023-10-11 11:41:59
合計ジャッジ時間 20,568 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 140 ms
56,180 KB
testcase_01 AC 139 ms
56,012 KB
testcase_02 AC 603 ms
77,472 KB
testcase_03 AC 837 ms
111,080 KB
testcase_04 AC 788 ms
111,812 KB
testcase_05 AC 841 ms
113,816 KB
testcase_06 AC 796 ms
113,184 KB
testcase_07 AC 753 ms
90,600 KB
testcase_08 AC 689 ms
76,264 KB
testcase_09 AC 689 ms
96,368 KB
testcase_10 AC 910 ms
130,504 KB
testcase_11 AC 870 ms
126,268 KB
testcase_12 AC 820 ms
113,568 KB
testcase_13 AC 802 ms
111,312 KB
testcase_14 AC 582 ms
109,516 KB
testcase_15 AC 617 ms
86,608 KB
testcase_16 AC 640 ms
78,108 KB
testcase_17 AC 309 ms
60,352 KB
testcase_18 AC 406 ms
62,168 KB
testcase_19 AC 307 ms
60,140 KB
testcase_20 AC 382 ms
60,628 KB
testcase_21 AC 397 ms
60,468 KB
testcase_22 AC 417 ms
60,832 KB
testcase_23 AC 140 ms
55,652 KB
testcase_24 AC 138 ms
56,144 KB
testcase_25 AC 305 ms
59,812 KB
testcase_26 AC 138 ms
56,160 KB
testcase_27 AC 137 ms
55,812 KB
testcase_28 AC 142 ms
56,460 KB
testcase_29 AC 140 ms
55,856 KB
testcase_30 AC 418 ms
60,276 KB
testcase_31 AC 142 ms
56,112 KB
testcase_32 AC 141 ms
55,992 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		// 入力
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		String str = sc.next();
		String[] move = str.split("");
		
		// 移動
		int[][] grid = new int[N+1][N+1];
		for(int i = 0; i <= N; i++){
			for(int j = 0; j <= N; j++){
				grid[i][j] = 1;
			}
		}
		
		int posX = 0;
		int posY = N;
		grid[N][0] = 0;
		for(int i = 0; i < M; i++){
			if(move[i].equals("R")){
				posX++;
			}
			else if(move[i].equals("L")){
				posX--;
			}
			else if(move[i].equals("D")){
				posY++;
			}
			else if(move[i].equals("U")){
				posY--;
			}
			grid[posY][posX] = 0;
		}
		
		// 出力
		for(int i = 0; i <= N; i++){
			for(int j = 0; j <= N; j++){
				System.out.print(grid[i][j] + " ");
			}
			System.out.println("");
		}
	}

}
0