結果
| 問題 | No.208 王将 |
| コンテスト | |
| ユーザー |
r.suzuki
|
| 提出日時 | 2016-01-08 16:41:23 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,440 bytes |
| 記録 | |
| コンパイル時間 | 3,453 ms |
| コンパイル使用メモリ | 77,708 KB |
| 実行使用メモリ | 54,412 KB |
| 最終ジャッジ日時 | 2024-09-19 13:08:58 |
| 合計ジャッジ時間 | 7,579 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 21 WA * 2 |
ソースコード
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();
}
}
r.suzuki