Submission #12489267
Source Code Expand
{-# LANGUAGE BangPatterns #-}
import Control.Exception (assert)
import Control.Monad
import Control.Monad.Primitive
import qualified Control.Monad.ST as ST
import qualified Data.Array.IO as IO
import qualified Data.Array.ST as ST
import qualified Data.Array.Unboxed as A
import Data.Bits
import qualified Data.ByteString.Char8 as BS
import Data.Char
import Data.Foldable
import Data.List
import Data.Maybe
import qualified Data.Sequence as Seq
import qualified Data.Set as Set
import qualified Data.Vector.Unboxed as V
import qualified Data.Vector.Unboxed.Mutable as VM
import Debug.Trace
readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
getIntVec n = V.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
readInteger = fst . fromJust . BS.readInteger
readIntegerList = map readInteger . BS.words
getInteger = readInteger <$> BS.getLine
getIntegerList = readIntegerList <$> BS.getLine
inf :: Int
inf = 10^18
main = do
s <- getLine
-- dropsS, dropsH, dropsD, dropsC : S, H, D, C を狙ったときのすて札
-- bS, bH, bD, bC : bit mask A,K,Q,J,10 (5-bit)
let solve :: String -> [String] -> [String] -> [String] -> [String] ->
Int -> Int -> Int -> Int -> String
solve (c1:c2:cs) dropsS dropsH dropsD dropsC bS bH bD bC =
let cs' = if c2 == '1' then drop 1 cs else cs
b0 | c1 == 'S' = bS
| c1 == 'H' = bH
| c1 == 'D' = bD
| c1 == 'C' = bC
b | c2 == '1' = 1
| c2 == 'J' = 2
| c2 == 'Q' = 4
| c2 == 'K' = 8
| c2 == 'A' = 16
| otherwise = 0
b' = b0 .|. b
bS' = if c1 == 'S' then b' else bS
bH' = if c1 == 'H' then b' else bH
bD' = if c1 == 'D' then b' else bD
bC' = if c1 == 'C' then b' else bC
d = [c1,c2] ++ if c2 == '1' then "0" else ""
dropsS' = dropsS ++ if c1 /= 'S' || b == 0 then [d] else []
dropsH' = dropsH ++ if c1 /= 'H' || b == 0 then [d] else []
dropsD' = dropsD ++ if c1 /= 'D' || b == 0 then [d] else []
dropsC' = dropsC ++ if c1 /= 'C' || b == 0 then [d] else []
drops | c1 == 'S' = dropsS
| c1 == 'H' = dropsH
| c1 == 'D' = dropsD
| c1 == 'C' = dropsC
in
if b' == 31
then concat drops
else solve cs' dropsS' dropsH' dropsD' dropsC' bS' bH' bD' bC'
ans = solve s [] [] [] [] 0 0 0 0
if null ans
then print 0
else putStrLn ans
Submission Info
| Submission Time | |
|---|---|
| Task | B - ロイヤルストレートフラッシュ |
| User | unnohideyuki |
| Language | Haskell (GHC 7.10.3) |
| Score | 100 |
| Code Size | 2940 Byte |
| Status | AC |
| Exec Time | 1 ms |
| Memory | 508 KiB |
Judge Result
| Set Name | All | ||
|---|---|---|---|
| Score / Max Score | 100 / 100 | ||
| Status |
|
| Set Name | Test Cases |
|---|---|
| All | 00_sample1, 00_sample2, 10_input00, 10_input01, 10_input02, 10_input03, 10_input04, 10_input05, 10_input06, 10_input07, 10_input08, 10_input09, 10_input10, 10_input11, 10_input12, 10_input13, 10_input14, 10_input15, 10_input16, 10_input17, 10_input18, 10_input19, 10_input20, 10_input21, 10_input22, 10_input23, 10_input24, 10_input25, 10_input26, 10_input27, 10_input28, 10_input29, 10_input30, 10_input31, 10_input32, 10_input33, 10_input34, 10_input35, 10_input36, 10_input37, 10_input38, 10_input39, 10_input40, 10_input41, 10_input42, 10_input43, 10_input44, 10_input45, 10_input46, 10_input47, 10_input48, 10_input49, 10_input50, 10_input51, 10_input52, 10_input53, 10_input54, 10_input55, 10_input56, 10_input57, 10_input58, 10_input59, 10_input60, 10_input61, 10_input62, 10_input63, 10_input64, 10_input65, 10_input66, 10_input67, 10_input68, 10_input69 |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 00_sample1 | AC | 1 ms | 380 KiB |
| 00_sample2 | AC | 1 ms | 380 KiB |
| 10_input00 | AC | 1 ms | 508 KiB |
| 10_input01 | AC | 1 ms | 508 KiB |
| 10_input02 | AC | 1 ms | 508 KiB |
| 10_input03 | AC | 1 ms | 508 KiB |
| 10_input04 | AC | 1 ms | 508 KiB |
| 10_input05 | AC | 1 ms | 508 KiB |
| 10_input06 | AC | 1 ms | 508 KiB |
| 10_input07 | AC | 1 ms | 508 KiB |
| 10_input08 | AC | 1 ms | 508 KiB |
| 10_input09 | AC | 1 ms | 508 KiB |
| 10_input10 | AC | 1 ms | 508 KiB |
| 10_input11 | AC | 1 ms | 508 KiB |
| 10_input12 | AC | 1 ms | 508 KiB |
| 10_input13 | AC | 1 ms | 380 KiB |
| 10_input14 | AC | 1 ms | 380 KiB |
| 10_input15 | AC | 1 ms | 508 KiB |
| 10_input16 | AC | 1 ms | 508 KiB |
| 10_input17 | AC | 1 ms | 508 KiB |
| 10_input18 | AC | 1 ms | 508 KiB |
| 10_input19 | AC | 1 ms | 508 KiB |
| 10_input20 | AC | 1 ms | 508 KiB |
| 10_input21 | AC | 1 ms | 508 KiB |
| 10_input22 | AC | 1 ms | 508 KiB |
| 10_input23 | AC | 1 ms | 508 KiB |
| 10_input24 | AC | 1 ms | 508 KiB |
| 10_input25 | AC | 1 ms | 508 KiB |
| 10_input26 | AC | 1 ms | 508 KiB |
| 10_input27 | AC | 1 ms | 508 KiB |
| 10_input28 | AC | 1 ms | 380 KiB |
| 10_input29 | AC | 1 ms | 508 KiB |
| 10_input30 | AC | 1 ms | 508 KiB |
| 10_input31 | AC | 1 ms | 380 KiB |
| 10_input32 | AC | 1 ms | 508 KiB |
| 10_input33 | AC | 1 ms | 508 KiB |
| 10_input34 | AC | 1 ms | 508 KiB |
| 10_input35 | AC | 1 ms | 508 KiB |
| 10_input36 | AC | 1 ms | 380 KiB |
| 10_input37 | AC | 1 ms | 508 KiB |
| 10_input38 | AC | 1 ms | 508 KiB |
| 10_input39 | AC | 1 ms | 508 KiB |
| 10_input40 | AC | 1 ms | 508 KiB |
| 10_input41 | AC | 1 ms | 508 KiB |
| 10_input42 | AC | 1 ms | 508 KiB |
| 10_input43 | AC | 1 ms | 508 KiB |
| 10_input44 | AC | 1 ms | 508 KiB |
| 10_input45 | AC | 1 ms | 508 KiB |
| 10_input46 | AC | 1 ms | 508 KiB |
| 10_input47 | AC | 1 ms | 508 KiB |
| 10_input48 | AC | 1 ms | 508 KiB |
| 10_input49 | AC | 1 ms | 508 KiB |
| 10_input50 | AC | 1 ms | 508 KiB |
| 10_input51 | AC | 1 ms | 508 KiB |
| 10_input52 | AC | 1 ms | 380 KiB |
| 10_input53 | AC | 1 ms | 380 KiB |
| 10_input54 | AC | 1 ms | 508 KiB |
| 10_input55 | AC | 1 ms | 508 KiB |
| 10_input56 | AC | 1 ms | 508 KiB |
| 10_input57 | AC | 1 ms | 508 KiB |
| 10_input58 | AC | 1 ms | 508 KiB |
| 10_input59 | AC | 1 ms | 508 KiB |
| 10_input60 | AC | 1 ms | 380 KiB |
| 10_input61 | AC | 1 ms | 508 KiB |
| 10_input62 | AC | 1 ms | 508 KiB |
| 10_input63 | AC | 1 ms | 380 KiB |
| 10_input64 | AC | 1 ms | 380 KiB |
| 10_input65 | AC | 1 ms | 508 KiB |
| 10_input66 | AC | 1 ms | 508 KiB |
| 10_input67 | AC | 1 ms | 508 KiB |
| 10_input68 | AC | 1 ms | 508 KiB |
| 10_input69 | AC | 1 ms | 508 KiB |