結果
| 問題 |
No.1133 キムワイプイーター
|
| ユーザー |
tenten
|
| 提出日時 | 2020-08-17 22:33:43 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 413 ms / 2,000 ms |
| コード長 | 917 bytes |
| コンパイル時間 | 2,523 ms |
| コンパイル使用メモリ | 79,340 KB |
| 実行使用メモリ | 52,924 KB |
| 最終ジャッジ日時 | 2024-10-11 11:27:33 |
| 合計ジャッジ時間 | 12,780 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 31 |
ソースコード
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);
}
}
tenten