結果
問題 | No.208 王将 |
ユーザー | r.suzuki |
提出日時 | 2016-01-08 16:41:23 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,440 bytes |
コンパイル時間 | 3,859 ms |
コンパイル使用メモリ | 78,432 KB |
実行使用メモリ | 57,632 KB |
最終ジャッジ日時 | 2023-10-19 16:48:56 |
合計ジャッジ時間 | 8,662 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 133 ms
57,488 KB |
testcase_01 | AC | 137 ms
57,432 KB |
testcase_02 | AC | 140 ms
57,372 KB |
testcase_03 | AC | 136 ms
57,492 KB |
testcase_04 | AC | 137 ms
57,500 KB |
testcase_05 | AC | 137 ms
57,496 KB |
testcase_06 | AC | 136 ms
57,488 KB |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | AC | 143 ms
57,576 KB |
testcase_10 | AC | 137 ms
57,432 KB |
testcase_11 | AC | 140 ms
57,500 KB |
testcase_12 | AC | 139 ms
57,412 KB |
testcase_13 | AC | 135 ms
57,392 KB |
testcase_14 | AC | 135 ms
57,436 KB |
testcase_15 | AC | 137 ms
57,176 KB |
testcase_16 | AC | 133 ms
57,464 KB |
testcase_17 | AC | 136 ms
57,328 KB |
testcase_18 | AC | 135 ms
57,612 KB |
testcase_19 | AC | 133 ms
57,412 KB |
testcase_20 | AC | 137 ms
57,452 KB |
testcase_21 | AC | 138 ms
57,488 KB |
testcase_22 | AC | 140 ms
57,460 KB |
testcase_23 | AC | 137 ms
57,136 KB |
testcase_24 | AC | 137 ms
57,472 KB |
ソースコード
public class No_208 { static boolean straight(int x, int y) { if (x == 0 || y == 0 || Math.abs(x) == Math.abs(y)) { return true; } else { return false; } } static String direction(int x, int y) { if (x == 0) { if (y > 0) return "N"; else return "S"; } else if (y == 0) { if (x > 0) return "E"; else return "W"; } else if (x == y) { if (x > 0) return "NE"; else return "SW"; } else { if (x > y) return "SE"; else return "NW"; } } static boolean inTheWay(String dir, int X, int Y, int fuX, int fuY) { switch (dir) { case "N": case "NE": if (Y > fuY) return true; else return false; case "E": case "SE": if (X > fuX) return true; else return false; case "S": case "SW": if (Y < fuY) return true; else return false; case "W": case "NW": if (X < fuX) return true; else return false; } return false; } public static void main(String[] args) { java.util.Scanner sc = new java.util.Scanner(System.in); int X, Y, fuX, fuY; X = sc.nextInt(); Y = sc.nextInt(); fuX = sc.nextInt(); fuY = sc.nextInt(); int step = Math.max(X, Y); if (straight(X, Y) && straight(fuX, fuY)) { String dir = direction(X, Y); if (dir.equals(direction(fuX, fuY))) { if (inTheWay(dir, X, Y, fuX, fuY)) { step += 1; } } } System.out.println(step); sc.close(); } }