結果
| 問題 |
No.1806 Rotating Golem
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-02-08 17:14:02 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 131 ms / 2,000 ms |
| コード長 | 684 bytes |
| コンパイル時間 | 2,170 ms |
| コンパイル使用メモリ | 75,380 KB |
| 実行使用メモリ | 54,288 KB |
| 最終ジャッジ日時 | 2024-06-23 12:41:46 |
| 合計ジャッジ時間 | 5,209 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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();
}
}