結果

問題 No.401 数字の渦巻き
ユーザー kuuso1kuuso1
提出日時 2016-08-25 23:34:36
言語 F#
(F# 4.0)
結果
AC  
実行時間 92 ms / 2,000 ms
コード長 998 bytes
コンパイル時間 5,601 ms
コンパイル使用メモリ 169,264 KB
実行使用メモリ 25,000 KB
最終ジャッジ日時 2023-08-07 21:53:19
合計ジャッジ時間 10,232 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 90 ms
22,788 KB
testcase_01 AC 91 ms
22,912 KB
testcase_02 AC 90 ms
23,056 KB
testcase_03 AC 90 ms
22,888 KB
testcase_04 AC 91 ms
22,856 KB
testcase_05 AC 89 ms
22,976 KB
testcase_06 AC 92 ms
22,932 KB
testcase_07 AC 90 ms
22,896 KB
testcase_08 AC 91 ms
22,948 KB
testcase_09 AC 91 ms
24,980 KB
testcase_10 AC 91 ms
24,964 KB
testcase_11 AC 90 ms
20,916 KB
testcase_12 AC 91 ms
22,808 KB
testcase_13 AC 91 ms
24,948 KB
testcase_14 AC 90 ms
23,004 KB
testcase_15 AC 92 ms
22,940 KB
testcase_16 AC 92 ms
24,952 KB
testcase_17 AC 90 ms
22,996 KB
testcase_18 AC 90 ms
24,996 KB
testcase_19 AC 90 ms
24,900 KB
testcase_20 AC 91 ms
24,976 KB
testcase_21 AC 90 ms
22,940 KB
testcase_22 AC 90 ms
22,860 KB
testcase_23 AC 91 ms
22,824 KB
testcase_24 AC 92 ms
24,872 KB
testcase_25 AC 90 ms
23,060 KB
testcase_26 AC 90 ms
22,912 KB
testcase_27 AC 89 ms
22,896 KB
testcase_28 AC 91 ms
25,000 KB
testcase_29 AC 92 ms
24,920 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) F# Compiler version 11.0.0.0 for F# 5.0
Copyright (c) Microsoft Corporation. All Rights Reserved.

ソースコード

diff #

open System

let InRange ll ul i j = ( ll <= i ) && ( i < ul ) && ( ll <= j ) && ( j < ul )


type Sol() =
    member this.Solve() = 
        
        let N = stdin.ReadLine() |> int
        
        let dx = [1;0;-1;0]
        let dy = [0;1;0;-1]
        
        let rec f i j t n (a:int [] [] ) =
            //printfn "%d %d %d %d" i j t n
            if a.[i].[j] <> 0 then () else 
                a.[i].[j] <- n
                let ny = i + dy.[t]
                let nx = j + dx.[t]
                if (InRange 0 N ny nx) && (a.[ny].[nx] = 0) then f ny nx t (n+1) a 
                elif N <> 1 then f (i + dy.[(t+1)%4]) (j + dx.[(t+1)%4]) ((t+1)%4) (n+1) a
                    
        
        let A = Array.zeroCreate<int[]> N
        for i = 0 to (N-1) do A.[i] <- Array.zeroCreate<int> N
        
        f 0 0 0 1 A
        
        for i = 0 to (N-1) do  String.Join(" ", (A.[i] |> Array.map (sprintf "%03d"))) |> printfn "%s"
        
        ()
let mySol = new Sol()
mySol.Solve()
0