結果
| 問題 |
No.401 数字の渦巻き
|
| コンテスト | |
| ユーザー |
aimy
|
| 提出日時 | 2017-04-24 12:51:42 |
| 言語 | Haskell (9.10.1) |
| 結果 |
AC
|
| 実行時間 | 6 ms / 2,000 ms |
| コード長 | 497 bytes |
| コンパイル時間 | 6,647 ms |
| コンパイル使用メモリ | 172,104 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-13 11:50:02 |
| 合計ジャッジ時間 | 3,139 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 30 |
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.8.2/environments/default [1 of 2] Compiling Main ( Main.hs, Main.o ) [2 of 2] Linking a.out
ソースコード
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
aimy