結果

問題 No.401 数字の渦巻き
ユーザー gemmarogemmaro
提出日時 2020-01-15 16:53:26
言語 Haskell
(9.8.2)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 735 bytes
コンパイル時間 7,574 ms
コンパイル使用メモリ 160,684 KB
実行使用メモリ 8,256 KB
最終ジャッジ日時 2023-09-01 22:41:36
合計ジャッジ時間 9,526 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,916 KB
testcase_01 AC 3 ms
6,904 KB
testcase_02 AC 3 ms
6,940 KB
testcase_03 AC 3 ms
7,044 KB
testcase_04 AC 2 ms
6,948 KB
testcase_05 AC 2 ms
7,016 KB
testcase_06 AC 3 ms
7,036 KB
testcase_07 AC 3 ms
6,988 KB
testcase_08 AC 3 ms
7,148 KB
testcase_09 AC 2 ms
7,068 KB
testcase_10 AC 3 ms
7,172 KB
testcase_11 AC 2 ms
7,196 KB
testcase_12 AC 3 ms
7,240 KB
testcase_13 AC 3 ms
7,244 KB
testcase_14 AC 3 ms
7,232 KB
testcase_15 AC 3 ms
7,320 KB
testcase_16 AC 3 ms
7,364 KB
testcase_17 AC 3 ms
7,456 KB
testcase_18 AC 3 ms
7,500 KB
testcase_19 AC 3 ms
7,512 KB
testcase_20 AC 3 ms
7,624 KB
testcase_21 AC 3 ms
7,628 KB
testcase_22 AC 3 ms
7,732 KB
testcase_23 AC 4 ms
7,876 KB
testcase_24 AC 4 ms
7,980 KB
testcase_25 AC 3 ms
7,912 KB
testcase_26 AC 4 ms
8,068 KB
testcase_27 AC 4 ms
8,076 KB
testcase_28 AC 4 ms
8,140 KB
testcase_29 AC 4 ms
8,256 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.6.1/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )
[2 of 2] Linking a.out

ソースコード

diff #

main = readLn >>= putStr . output . (solve 1)

solve :: Int -> Int -> [[Int]]
solve m 1 = [[m]]
solve m 2 = [ [m, m + 1], [m + 3, m + 2] ]
solve m n = top ++ mids ++ bot
    where centerArr = (solve (m + 4 * n - 4) (n - 2))
          top = [ [ i | i <- [m .. m + n - 1] ] ]
          mids = [ row i n m (centerArr !! i) | i <- [0 .. n - 3] ]
          bot = [ reverse [ i | i <- [m + 2 * n - 2 .. m + 3 * n - 3] ] ]

row :: Int -> Int -> Int -> [Int] -> [Int]
row i n m centers = left ++ centers ++ right
    where left = [m + 4 * n - 5 - i]
          right = [m + n + i]

output :: [[Int]] -> String
output = unlines . (map (\xs -> unwords $ map show' xs))

show' :: Int -> String
show' n = reverse $ take 3 $ reverse $ "00" ++ show n
0