結果
| 問題 | No.1806 Rotating Golem |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-02-08 17:14:02 |
| 言語 | Java (openjdk 25.0.2) |
| 結果 |
AC
|
| 実行時間 | 56 ms / 2,000 ms |
| コード長 | 684 bytes |
| 記録 | |
| コンパイル時間 | 1,944 ms |
| コンパイル使用メモリ | 84,092 KB |
| 実行使用メモリ | 46,632 KB |
| 最終ジャッジ日時 | 2026-03-08 07:08:11 |
| 合計ジャッジ時間 | 3,644 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 13 |
ソースコード
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scn = new Scanner(System.in);
String start = scn.nextLine();
String end = scn.nextLine();
ArrayList<String> list = new ArrayList<>(Arrays.asList("N", "E", "S", "W"));
// {北, 東, 南, 西};
int startIndex = list.indexOf(start);
int i = startIndex;
boolean flg = true;
int count = 0;
while (flg) {
if (list.get(i).equals(end)) {
System.out.println(count);
break;
} else {
i = (i + 1) % 4;
if(i == startIndex) {
flg = false;
}
count += 1;
}
}
scn.close();
}
}