結果
| 問題 |
No.208 王将
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-03-15 21:01:27 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 660 bytes |
| コンパイル時間 | 2,988 ms |
| コンパイル使用メモリ | 74,120 KB |
| 実行使用メモリ | 832,000 KB |
| 最終ジャッジ日時 | 2024-11-25 11:34:05 |
| 合計ジャッジ時間 | 10,344 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 19 WA * 2 TLE * 2 |
ソースコード
import java.util.*;
import java.io.*;
import java.math.*;
public class No208 {
public static int ans = Integer.MAX_VALUE;
public static int x, y, x2, y2;
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
x = sc.nextInt();
y = sc.nextInt();
x2 = sc.nextInt();
y2 = sc.nextInt();
sou(0, 0, 0);
System.out.println(ans);
}
public static void sou(int cx, int cy, int cnt) {
if(cx > x || cy > y) return;
if(cx == x && cy == y) ans = Math.min(cnt, ans);
if(cx+1 != x2 || cy+1 != y2) sou(cx+1, cy+1, cnt+1);
if(cx != x2 || cy+1 != y2) sou(cx, cy+1, cnt+1);
if(cx+1 != x2 || cy != y2) sou(cx+1, cy, cnt+1);
}
}