結果

問題 No.197 手品
ユーザー Haar
提出日時 2016-09-01 07:21:01
言語 Haskell
(9.10.1)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 696 bytes
コンパイル時間 5,718 ms
コンパイル使用メモリ 169,472 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-20 03:49:42
合計ジャッジ時間 7,255 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 43
権限があれば一括ダウンロードができます
コンパイルメッセージ
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:1: warning: [GHC-94817] [-Wtabs]
    Tab character found here, and in 40 further locations.
    Suggested fix: Please use spaces instead.
  |
6 |         bef <- sum . zipWith (*) (iterate (*2) 1) . map convert <$> getLine
  | ^^^^^^^^
[2 of 2] Linking a.out

ソースコード

diff #

import Control.Applicative
import Data.Bits

main :: IO()
main = do
	bef <- sum . zipWith (*) (iterate (*2) 1) . map convert <$> getLine
	n <- readLn
	aft <-sum . zipWith (*) (iterate (*2) 1) . map convert <$>  getLine

	let nb = popCount bef
	let na = popCount aft

	putStrLn $ if nb /= na
		then "SUCCESS"
		else if bef == 0 || bef == 7
			then "FAILURE"
			else case n of
				0 -> if bef == aft then "FAILURE" else "SUCCESS"
				1	| isLat bef && (bef == aft || isCen aft) -> "FAILURE"
					| isCen bef && isLat aft -> "FAILURE"
					| otherwise -> "SUCCESS"
				_ -> "FAILURE"

isLat x = elem x [1,3,4,6]
isCen x = elem x [2,5]

convert :: Char -> Int
convert x
	| x == 'o' = 0
	| x == 'x' = 1
0