結果
問題 | No.1806 Rotating Golem |
ユーザー | マサ |
提出日時 | 2022-02-08 17:14:02 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 126 ms / 2,000 ms |
コード長 | 684 bytes |
コンパイル時間 | 2,493 ms |
コンパイル使用メモリ | 74,364 KB |
実行使用メモリ | 56,040 KB |
最終ジャッジ日時 | 2023-09-05 17:11:13 |
合計ジャッジ時間 | 6,377 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 123 ms
55,888 KB |
testcase_01 | AC | 122 ms
55,756 KB |
testcase_02 | AC | 123 ms
55,680 KB |
testcase_03 | AC | 122 ms
55,880 KB |
testcase_04 | AC | 123 ms
55,984 KB |
testcase_05 | AC | 124 ms
55,624 KB |
testcase_06 | AC | 123 ms
56,040 KB |
testcase_07 | AC | 123 ms
55,692 KB |
testcase_08 | AC | 124 ms
56,036 KB |
testcase_09 | AC | 125 ms
55,776 KB |
testcase_10 | AC | 124 ms
55,804 KB |
testcase_11 | AC | 123 ms
55,924 KB |
testcase_12 | AC | 126 ms
55,820 KB |
testcase_13 | AC | 126 ms
55,796 KB |
testcase_14 | AC | 126 ms
55,688 KB |
testcase_15 | AC | 124 ms
55,676 KB |
ソースコード
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(); } }