結果

問題 No.1133 キムワイプイーター
ユーザー tentententen
提出日時 2020-08-17 22:33:43
言語 Java21
(openjdk 21)
結果
AC  
実行時間 350 ms / 2,000 ms
コード長 917 bytes
コンパイル時間 2,021 ms
コンパイル使用メモリ 79,468 KB
実行使用メモリ 64,036 KB
最終ジャッジ日時 2024-04-19 19:15:12
合計ジャッジ時間 10,172 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 98 ms
54,116 KB
testcase_01 AC 109 ms
54,012 KB
testcase_02 AC 240 ms
57,060 KB
testcase_03 AC 301 ms
64,036 KB
testcase_04 AC 311 ms
63,852 KB
testcase_05 AC 308 ms
63,552 KB
testcase_06 AC 294 ms
63,868 KB
testcase_07 AC 288 ms
59,272 KB
testcase_08 AC 246 ms
57,228 KB
testcase_09 AC 308 ms
61,220 KB
testcase_10 AC 334 ms
63,768 KB
testcase_11 AC 345 ms
63,756 KB
testcase_12 AC 309 ms
64,016 KB
testcase_13 AC 350 ms
63,572 KB
testcase_14 AC 268 ms
61,300 KB
testcase_15 AC 272 ms
59,732 KB
testcase_16 AC 240 ms
57,276 KB
testcase_17 AC 123 ms
54,392 KB
testcase_18 AC 145 ms
54,268 KB
testcase_19 AC 116 ms
53,272 KB
testcase_20 AC 130 ms
53,764 KB
testcase_21 AC 128 ms
52,976 KB
testcase_22 AC 133 ms
54,420 KB
testcase_23 AC 120 ms
54,156 KB
testcase_24 AC 103 ms
52,820 KB
testcase_25 AC 122 ms
53,172 KB
testcase_26 AC 112 ms
54,140 KB
testcase_27 AC 102 ms
52,880 KB
testcase_28 AC 104 ms
53,116 KB
testcase_29 AC 101 ms
52,992 KB
testcase_30 AC 130 ms
54,260 KB
testcase_31 AC 97 ms
52,548 KB
testcase_32 AC 109 ms
54,004 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		HashSet<Integer> set = new HashSet<>();
		set.add(0);
		char[] arr = sc.next().toCharArray();
		int current = 0;
		for (char c : arr) {
		    if (c == 'L') {
		        current--;
		    } else if (c == 'U') {
		        current += n + 1;
		    } else if (c == 'D') {
		        current -= n + 1;
		    } else {
		        current++;
		    }
		    set.add(current);
		}
		StringBuilder sb = new StringBuilder();
		for (int i = n; i >= 0; i--) {
		    for (int j = 0; j <= n; j++) {
		        if (j > 0) {
		            sb.append(" ");
		        }
		        if (set.contains(i * (n + 1) + j)) {
		            sb.append("0");
		        } else {
		            sb.append("1");
		        }
		    }
		    sb.append("\n");
		}
		System.out.print(sb);
	}
}
0