結果
問題 | No.401 数字の渦巻き |
ユーザー | guricerin |
提出日時 | 2020-01-23 12:22:53 |
言語 | F# (.NET 7) |
結果 |
AC
|
実行時間 | 87 ms / 2,000 ms |
コード長 | 1,497 bytes |
コンパイル時間 | 6,215 ms |
コンパイル使用メモリ | 166,580 KB |
実行使用メモリ | 25,012 KB |
最終ジャッジ日時 | 2023-09-26 07:30:50 |
合計ジャッジ時間 | 10,037 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge15 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 86 ms
24,856 KB |
testcase_01 | AC | 85 ms
25,012 KB |
testcase_02 | AC | 86 ms
25,008 KB |
testcase_03 | AC | 86 ms
24,996 KB |
testcase_04 | AC | 85 ms
24,856 KB |
testcase_05 | AC | 84 ms
24,908 KB |
testcase_06 | AC | 84 ms
22,896 KB |
testcase_07 | AC | 85 ms
23,016 KB |
testcase_08 | AC | 85 ms
23,000 KB |
testcase_09 | AC | 84 ms
22,832 KB |
testcase_10 | AC | 84 ms
22,932 KB |
testcase_11 | AC | 84 ms
22,844 KB |
testcase_12 | AC | 85 ms
20,872 KB |
testcase_13 | AC | 85 ms
22,924 KB |
testcase_14 | AC | 82 ms
22,888 KB |
testcase_15 | AC | 85 ms
22,960 KB |
testcase_16 | AC | 87 ms
22,884 KB |
testcase_17 | AC | 85 ms
22,956 KB |
testcase_18 | AC | 83 ms
20,912 KB |
testcase_19 | AC | 83 ms
20,928 KB |
testcase_20 | AC | 84 ms
22,868 KB |
testcase_21 | AC | 85 ms
22,984 KB |
testcase_22 | AC | 84 ms
20,932 KB |
testcase_23 | AC | 84 ms
22,968 KB |
testcase_24 | AC | 86 ms
22,912 KB |
testcase_25 | AC | 84 ms
20,924 KB |
testcase_26 | AC | 84 ms
22,932 KB |
testcase_27 | AC | 83 ms
22,916 KB |
testcase_28 | AC | 84 ms
23,004 KB |
testcase_29 | AC | 84 ms
22,888 KB |
コンパイルメッセージ
Microsoft (R) F# Compiler version 11.0.0.0 for F# 5.0 Copyright (c) Microsoft Corporation. All Rights Reserved.
ソースコード
open System open System.Collections.Generic [<AutoOpen>] module Cin = let read f = stdin.ReadLine() |> f let reada f = stdin.ReadLine().Split() |> Array.map f let readChars() = read string |> Seq.toArray let readInts() = readChars() |> Array.map (fun x -> Convert.ToInt32(x.ToString())) [<AutoOpen>] module Cout = let writer = new IO.StreamWriter(new IO.BufferedStream(Console.OpenStandardOutput())) let print (s: string) = writer.Write s let println (s: string) = writer.WriteLine s let inline puts (s: ^a) = string s |> println let main() = let n = read int let maze = Array2D.init n n (fun _ _ -> 0) let mutable d = 0 let nextD() = d <- (d + 1) % 4 let mutable (x, y) = (0, 0) let step x y = match d with | 0 -> x + 1, y | 1 -> x, y + 1 | 2 -> x - 1, y | _ -> x, y - 1 let isOut x y = not (0 <= x && x < n && 0 <= y && y < n) for i in 0 .. n * n - 1 do let a = i + 1 maze.[y, x] <- a let mutable (nx, ny) = step x y if isOut nx ny then nextD() let a, b = step x y nx <- a ny <- b else if maze.[ny, nx] <> 0 then nextD() let a, b = step x y nx <- a ny <- b x <- nx y <- ny for i in 0 .. n - 1 do let s = maze.[i, *] |> Array.map (fun x -> sprintf "%03d" x) String.Join(" ", s) |> puts main() writer.Close()