結果

問題 No.1366 交換門松列・梅
ユーザー xsdxsd
提出日時 2022-07-02 16:48:01
言語 OCaml
(5.1.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 799 bytes
コンパイル時間 2,389 ms
コンパイル使用メモリ 19,560 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-18 07:56:46
合計ジャッジ時間 1,921 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

let () =
    let a = Array.init 3 (fun _ -> Scanf.scanf " %d" (fun a -> a)) in
    let b = Array.init 3 (fun _ -> Scanf.scanf " %d" (fun a -> a)) in
    let check i j =
        let check2 arr =
            arr.(0) <> arr.(1) && arr.(1) <> arr.(2) && arr.(2) <> arr.(0) && (
                (arr.(1) < arr.(0) && arr.(1) < arr.(2)) ||
                (arr.(1) > arr.(0) && arr.(1) > arr.(2))
            )

        in
        let a = Array.copy a in
        let b = Array.copy b in
        let c = a.(i) in
        a.(i) <- b.(j);
        b.(j) <- c;
        check2 a && check2 b
    in
    let rec loop i j =
        if j = 3 then false else
        if i = 3 then loop 0 (j + 1) else
            if check i j then true else loop (i + 1) j
    in
    print_endline @@ if loop 0 0 then "Yes" else "No"
0