結果
問題 | No.792 真理関数をつくろう |
ユーザー |
![]() |
提出日時 | 2019-03-22 17:17:54 |
言語 | Haskell (9.10.1) |
結果 |
AC
|
実行時間 | 50 ms / 2,000 ms |
コード長 | 656 bytes |
コンパイル時間 | 2,030 ms |
コンパイル使用メモリ | 172,800 KB |
実行使用メモリ | 24,064 KB |
最終ジャッジ日時 | 2024-09-19 02:29:17 |
合計ジャッジ時間 | 2,261 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 22 |
コンパイルメッセージ
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:6:35: warning: [GHC-63394] [-Wx-partial]
In the use of ‘head’
(imported from Data.List, 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."
|
6 | qsr_s <- replicateM (2^n) > getLine
| ^^^^
[2 of 2] Linking a.out
ソースコード
importControl.MonadimportData.Listmain = don <- read <$> getLine :: IO Intqsr_s <- replicateM (2^n) $ map head . words <$> getLinelet qsr_s_reduced = map init $ filter (('1'==) . last) qsr_sputStrLn $ "A=" ++ if length qsr_s_reduced < 2^n then genCNF (map genClause qsr_s_reduced) else "⊤"genClause::String->StringgenClause qs = concat $ intersperse "∧" $ map genLiteral $ zip qs [1..]wheregenLiteral::CharInt->StringgenLiteral (q,i) = (if q=='0' then "¬" else "") ++ "P_" ++ show igenCNF::String->StringgenCNF [] = "⊥"genCNF (c:[]) = "(" ++ c ++ ")"genCNF (c:cs) = "(" ++ c ++ ")∨" ++ genCNF cs