結果

問題 No.401 数字の渦巻き
ユーザー kuuso1kuuso1
提出日時 2016-08-25 23:29:33
言語 F#
(F# 4.0)
結果
RE  
実行時間 -
コード長 970 bytes
コンパイル時間 14,873 ms
コンパイル使用メモリ 201,720 KB
実行使用メモリ 36,480 KB
最終ジャッジ日時 2024-04-25 16:09:02
合計ジャッジ時間 18,482 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 AC 322 ms
35,048 KB
testcase_02 AC 323 ms
35,020 KB
testcase_03 AC 330 ms
35,172 KB
testcase_04 AC 319 ms
34,760 KB
testcase_05 AC 325 ms
35,164 KB
testcase_06 AC 320 ms
35,144 KB
testcase_07 AC 325 ms
34,772 KB
testcase_08 AC 328 ms
35,180 KB
testcase_09 AC 326 ms
35,192 KB
testcase_10 AC 328 ms
35,180 KB
testcase_11 AC 326 ms
35,424 KB
testcase_12 AC 333 ms
35,216 KB
testcase_13 AC 335 ms
34,788 KB
testcase_14 AC 337 ms
34,824 KB
testcase_15 AC 330 ms
34,976 KB
testcase_16 AC 333 ms
35,160 KB
testcase_17 AC 329 ms
35,324 KB
testcase_18 AC 330 ms
34,948 KB
testcase_19 AC 331 ms
35,312 KB
testcase_20 AC 330 ms
35,200 KB
testcase_21 AC 326 ms
34,976 KB
testcase_22 AC 330 ms
35,088 KB
testcase_23 AC 338 ms
35,240 KB
testcase_24 AC 328 ms
35,188 KB
testcase_25 AC 327 ms
34,548 KB
testcase_26 AC 323 ms
35,156 KB
testcase_27 AC 325 ms
34,916 KB
testcase_28 AC 327 ms
34,976 KB
testcase_29 AC 323 ms
35,308 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.fsproj を復元しました (294 ms)。
MSBuild のバージョン 17.9.6+a4ecab324 (.NET)
  main -> /home/judge/data/code/bin/Release/net8.0/main.dll
  main -> /home/judge/data/code/bin/Release/net8.0/publish/

ソースコード

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 else 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