結果

問題 No.208 王将
ユーザー tsunabittsunabit
提出日時 2020-03-15 21:01:27
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 660 bytes
コンパイル時間 3,263 ms
コンパイル使用メモリ 71,804 KB
実行使用メモリ 835,252 KB
最終ジャッジ日時 2023-08-16 21:12:01
合計ジャッジ時間 8,636 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 131 ms
56,076 KB
testcase_01 AC 122 ms
55,708 KB
testcase_02 AC 118 ms
55,928 KB
testcase_03 AC 119 ms
56,212 KB
testcase_04 AC 123 ms
56,036 KB
testcase_05 AC 128 ms
56,052 KB
testcase_06 AC 303 ms
55,920 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 120 ms
55,884 KB
testcase_10 AC 276 ms
55,604 KB
testcase_11 MLE -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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);
	}
}
0