結果
| 問題 | No.9017 ac-library 動作確認 |
| ユーザー |
|
| 提出日時 | 2026-09-06 14:04:40 |
| 言語 | Haskell (9.14.1 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 44 ms / 5,000 ms |
| + 478µs | |
| コード長 | 556 bytes |
| 記録 | |
| コンパイル時間 | 12,398 ms |
| コンパイル使用メモリ | 243,492 KB |
| 実行使用メモリ | 22,260 KB |
| 最終ジャッジ日時 | 2026-09-07 01:30:11 |
| 合計ジャッジ時間 | 14,037 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 6 |
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.14.1/environments/default
[1 of 2] Compiling Main ( Main.hs, Main.o )
Main.hs:9:11: warning: [GHC-63394] [-Wx-partial]
In the use of ‘head’
(imported from Prelude, but defined in GHC.Internal.List):
"This is a partial function, it throws an error on empty lists. Use pattern matching, 'Data.List.uncons' or 'Data.Maybe.listToMaybe' instead. Consider refactoring to use "Data.List.NonEmpty"."
|
9 | let n = head ints
| ^^^^
[2 of 2] Linking a.out
ソースコード
import qualified AtCoder.Dsu as Dsu
import Control.Monad (forM_)
import qualified Data.ByteString.Char8 as BS
import Data.Maybe (fromJust)
main :: IO ()
main = do
ints <- map (fst . fromJust . BS.readInt) . BS.words <$> BS.getContents
let n = head ints
m = ints !! 1
pairs (a : b : xs) = (a, b) : pairs xs
pairs _ = []
d <- Dsu.new n
forM_ (take m (pairs (drop 2 ints))) $ \(u, v) -> do
_ <- Dsu.merge d u v
pure ()
leaders <- mapM (Dsu.leader d) [0 .. n - 1]
print (length (filter id (zipWith (==) leaders [0 ..])))