結果

問題 No.179 塗り分け
ユーザー iwotiwot
提出日時 2020-06-21 22:05:03
言語 F#
(F# 4.0)
結果
AC  
実行時間 1,083 ms / 3,000 ms
コード長 1,299 bytes
コンパイル時間 5,111 ms
コンパイル使用メモリ 161,228 KB
実行使用メモリ 28,964 KB
最終ジャッジ日時 2023-09-30 21:29:01
合計ジャッジ時間 20,836 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
24,572 KB
testcase_01 AC 81 ms
24,632 KB
testcase_02 AC 81 ms
22,672 KB
testcase_03 AC 82 ms
22,876 KB
testcase_04 AC 81 ms
20,740 KB
testcase_05 AC 138 ms
26,844 KB
testcase_06 AC 82 ms
24,692 KB
testcase_07 AC 78 ms
24,636 KB
testcase_08 AC 831 ms
26,764 KB
testcase_09 AC 813 ms
26,848 KB
testcase_10 AC 82 ms
24,768 KB
testcase_11 AC 83 ms
22,868 KB
testcase_12 AC 712 ms
28,964 KB
testcase_13 AC 82 ms
24,824 KB
testcase_14 AC 83 ms
24,636 KB
testcase_15 AC 76 ms
22,596 KB
testcase_16 AC 80 ms
22,668 KB
testcase_17 AC 75 ms
22,656 KB
testcase_18 AC 97 ms
24,640 KB
testcase_19 AC 103 ms
22,584 KB
testcase_20 AC 1,083 ms
27,020 KB
testcase_21 AC 834 ms
28,896 KB
testcase_22 AC 839 ms
28,904 KB
testcase_23 AC 84 ms
22,696 KB
testcase_24 AC 833 ms
26,832 KB
testcase_25 AC 103 ms
24,880 KB
testcase_26 AC 191 ms
26,792 KB
testcase_27 AC 844 ms
28,940 KB
testcase_28 AC 114 ms
24,984 KB
testcase_29 AC 844 ms
28,800 KB
testcase_30 AC 401 ms
26,796 KB
testcase_31 AC 855 ms
28,832 KB
testcase_32 AC 294 ms
26,952 KB
testcase_33 AC 846 ms
28,820 KB
testcase_34 AC 225 ms
28,916 KB
testcase_35 AC 845 ms
28,772 KB
testcase_36 AC 80 ms
24,640 KB
testcase_37 AC 80 ms
24,664 KB
testcase_38 AC 80 ms
22,760 KB
testcase_39 AC 80 ms
22,728 KB
testcase_40 AC 81 ms
20,628 KB
testcase_41 AC 79 ms
22,592 KB
testcase_42 AC 80 ms
22,756 KB
testcase_43 AC 93 ms
24,724 KB
testcase_44 AC 152 ms
28,840 KB
testcase_45 AC 81 ms
22,760 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) F# Compiler version 11.0.0.0 for F# 5.0
Copyright (c) Microsoft Corporation. All Rights Reserved.

/home/judge/data/code/Main.fs(12,25): warning FS0058: Possible incorrect indentation: this token is offside of context started at position (11:52). Try indenting this token further or using standard formatting conventions.

/home/judge/data/code/Main.fs(12,25): warning FS0058: Possible incorrect indentation: this token is offside of context started at position (11:52). Try indenting this token further or using standard formatting conventions.

/home/judge/data/code/Main.fs(12,48): warning FS0058: Possible incorrect indentation: this token is offside of context started at position (11:52). Try indenting this token further or using standard formatting conventions.

/home/judge/data/code/Main.fs(12,48): warning FS0058: Possible incorrect indentation: this token is offside of context started at position (11:52). Try indenting this token further or using standard formatting conventions.

/home/judge/data/code/Main.fs(1,5): warning FS0025: Incomplete pattern matches on this expression. For example, the value '[|_; _; _|]' may indicate a case not covered by the pattern(s).

ソースコード

diff #

let [| H; W |] = stdin.ReadLine().Split(' ') |> Array.map int
let mutable sample = None
let S = [ for i in 0 .. H-1 do
            let s = stdin.ReadLine().Trim()
            yield [ for j in 0 .. s.Length - 1 do
                        if s.[j] = '#' && sample.IsNone then sample <- Some (i, j)
                        yield if s.[j] = '#' then 1 else 0 ] ]

let isAll0 ss = Array.map (fun s -> Array.sum s) ss |> Array.sum |> ((=) 0)

let list2array (ss:int list list) : int [] [] = [| for i in 0 .. ss.Length - 1 do
                        yield List.toArray ss.[i] |]

if sample.IsNone then printfn "NO"
else
    let h0 = fst sample.Value
    let w0 = snd sample.Value
    let result = seq {
        for dh in 0-h0 .. H-1-h0 do
        for dw in 0-w0 .. W-1-w0 do
            if dh <> 0 || dw <> 0 then
                let check = list2array S
                for h in 0 .. H-1 do
                for w in 0 .. W-1 do
                    if h+dh >= 0 && h+dh < H && w+dw >= 0 && w+dw < W && check.[h].[w] = 1 && check.[h+dh].[w+dw] = 1 then
                        check.[h].[w] <- 0
                        check.[h+dh].[w+dw] <- 0
                yield if isAll0 check then "YES" else "NO" }
    match Seq.tryFind ((=) "YES") result with
    | Some(_) -> printfn "YES"
    | _ -> printfn "NO"
0