結果

問題 No.1169 Row and Column and Diagonal
ユーザー poapoapoapoa
提出日時 2020-08-15 00:51:30
言語 Haskell
(9.8.2)
結果
AC  
実行時間 26 ms / 2,000 ms
コード長 400 bytes
コンパイル時間 7,678 ms
コンパイル使用メモリ 178,176 KB
実行使用メモリ 8,192 KB
最終ジャッジ日時 2024-04-18 23:25:32
合計ジャッジ時間 8,746 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 1 ms
6,812 KB
testcase_02 AC 2 ms
6,812 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 1 ms
6,940 KB
testcase_06 AC 5 ms
7,936 KB
testcase_07 AC 8 ms
7,936 KB
testcase_08 AC 11 ms
8,064 KB
testcase_09 AC 13 ms
7,936 KB
testcase_10 AC 25 ms
7,936 KB
testcase_11 AC 24 ms
8,064 KB
testcase_12 AC 25 ms
8,064 KB
testcase_13 AC 25 ms
8,192 KB
testcase_14 AC 26 ms
8,192 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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

ソースコード

diff #

import qualified Control.Monad as M

main :: IO ()
main = do
  n <- readLn :: IO Int
  let m = (n `div` 2) + 1
  M.forM_ [1..n] $ \i -> do
    putStrLn $ unwords . map show $ shift (i - 1) $ merge [1..m] [m+1..n]

merge :: [a] -> [a] -> [a]
merge xs     []     = xs
merge []     ys     = ys
merge (x:xs) (y:ys) = x : y : merge xs ys

shift :: Int -> [Int] -> [Int]
shift n xs = drop n xs ++ take n xs
0