結果

問題 No.401 数字の渦巻き
ユーザー aimyaimy
提出日時 2017-04-24 12:51:42
言語 Haskell
(9.8.2)
結果
AC  
実行時間 6 ms / 2,000 ms
コード長 497 bytes
コンパイル時間 11,096 ms
コンパイル使用メモリ 162,416 KB
実行使用メモリ 9,844 KB
最終ジャッジ日時 2023-10-11 13:03:58
合計ジャッジ時間 5,743 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,996 KB
testcase_01 AC 3 ms
6,976 KB
testcase_02 AC 2 ms
7,008 KB
testcase_03 AC 2 ms
7,032 KB
testcase_04 AC 3 ms
7,032 KB
testcase_05 AC 3 ms
7,084 KB
testcase_06 AC 3 ms
7,068 KB
testcase_07 AC 3 ms
7,224 KB
testcase_08 AC 3 ms
7,252 KB
testcase_09 AC 3 ms
7,176 KB
testcase_10 AC 2 ms
7,280 KB
testcase_11 AC 3 ms
7,272 KB
testcase_12 AC 3 ms
7,320 KB
testcase_13 AC 3 ms
7,436 KB
testcase_14 AC 3 ms
7,452 KB
testcase_15 AC 3 ms
7,640 KB
testcase_16 AC 3 ms
7,676 KB
testcase_17 AC 3 ms
7,744 KB
testcase_18 AC 3 ms
7,976 KB
testcase_19 AC 3 ms
7,980 KB
testcase_20 AC 4 ms
8,196 KB
testcase_21 AC 4 ms
8,292 KB
testcase_22 AC 4 ms
8,480 KB
testcase_23 AC 5 ms
8,604 KB
testcase_24 AC 5 ms
8,764 KB
testcase_25 AC 5 ms
9,020 KB
testcase_26 AC 6 ms
9,160 KB
testcase_27 AC 6 ms
9,448 KB
testcase_28 AC 6 ms
9,608 KB
testcase_29 AC 6 ms
9,844 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 = interact $ unlines . map (unwords . map show') . spiral . read
 where show' = reverse . take 3 . reverse . ("00"++) . show

spiral n = [[f x y | y<-[1..n]] | x<-[1..n]]
 where
  f x y
   | x==1 && y==1 = 1
   | x==n && y==n = 2*n - 1
   | x+y <= n && x==y = f (x-1) (y-1) + 4 * (n-2*(x-2)-1)
   | x+y <= n = if x<y then 1 + f x (y-1) else 1 + f (x+1) y
   | x+y > n && x==y = f (x+1) (y+1) + 4 * (n-2*(n-x-1)-2)
   | x+y > n = if x<y then f (x+1) y - 1 else 1 + f x (y+1)
   | otherwise = 0
0