結果
| 問題 | No.883 ぬりえ |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-09-15 08:48:43 |
| 言語 | Haskell (9.10.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 642 bytes |
| 記録 | |
| コンパイル時間 | 2,406 ms |
| コンパイル使用メモリ | 177,152 KB |
| 実行使用メモリ | 58,980 KB |
| 最終ジャッジ日時 | 2024-07-06 22:39:42 |
| 合計ジャッジ時間 | 2,743 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 16 WA * 3 |
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.8.2/environments/default
[1 of 2] Compiling Main ( Main.hs, Main.o )
Main.hs:13:9: warning: [GHC-63394] [-Wx-partial]
In the use of ‘head’
(imported from Prelude, but defined in GHC.List):
"This is a partial function, it throws an error on empty lists. Use pattern matching or Data.List.uncons instead. Consider refactoring to use Data.List.NonEmpty."
|
13 | c = head [x | x<-[0..k], x*x>=b]
| ^^^^
[2 of 2] Linking a.out
ソースコード
import Data.Array.IO
import Control.Monad
slice n [] = []
slice n xs = take n xs : slice n (drop n xs)
main = do
[n,k] <- map read . words <$> getLine :: IO [Int]
let
a = n `div` (k*k)
b = n `mod` (k*k)
c = head [x | x<-[0..k], x*x>=b]
m = a*k+c
ans <- newArray ((1,1),(m,m)) '.' :: IO (IOArray (Int,Int) Char)
forM [0..a-1] $ \i -> do
forM [1..k] $ \x -> do
forM [1..k] $ \y -> do
writeArray ans (i*k+x, i*k+y) '#'
forM [0..b-1] $ \i -> do
let
x = a*k + i`mod`c+1
y = a*k + i`div`c+1
writeArray ans (x,y) '#'
print m
mapM_ putStrLn =<< slice m <$> getElems ans