Submission #33862


Source Code Expand

Copy
import Control.Arrow
import Data.List
import Data.Maybe

main :: IO ()
main = interact $ lines >>> tail >>> map (filter (/='|') >>> map (\x -> if x == '-' then 1 else if x == 'o' then 2 else 0)) >>> res >>> solve >>> show >>> (++"\n")

res :: [[Int]] -> (Int,[[Int]])
res xss = let
    la = init xss
    an = last xss
  in ((fromJust $ elemIndex 2 an)`div`2, la)

solve :: (Int,[[Int]]) -> Int
solve (a,xss) = if length (xss !! 0) == 0 then 1 else (+1) $ fst $ until (snd >>> (==(-1))) (up xss) (a,length xss-1) where
  up :: [[Int]] -> (Int,Int) -> (Int,Int)
  up xss (0,h) = if xss !! h !! 0 == 1 then (1,h-1) else (0,h-1)
  up xss (a,h)
    | a == length (xss !! 0) =
      if xss !! h !! (a-1) == 1 then (a-1,h-1) else (a,h-1)
    | otherwise = 
      if xss !! h !! a == 1 then (a+1,h-1) else if xss !! h !! (a-1) == 1 then (a-1,h-1) else (a,h-1)

Submission Info

Submission Time
Task B - あみだくじ
User phi16
Language Haskell (GHC 7.4.1)
Score 100
Code Size 872 Byte
Status AC
Exec Time 40 ms
Memory 1464 KB

Judge Result

Set Name All
Score / Max Score 100 / 100
Status
AC × 34
Set Name Test Cases
All 00_min.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 00_sample_04.txt, 00_sample_05.txt, 01_rnd_00.txt, 01_rnd_01.txt, 01_rnd_02.txt, 01_rnd_03.txt, 01_rnd_04.txt, 01_rnd_05.txt, 01_rnd_06.txt, 01_rnd_07.txt, 01_rnd_08.txt, 01_rnd_09.txt, 01_rnd_10.txt, 01_rnd_11.txt, 01_rnd_12.txt, 01_rnd_13.txt, 01_rnd_14.txt, 01_rnd_15.txt, 01_rnd_16.txt, 01_rnd_17.txt, 01_rnd_18.txt, 01_rnd_19.txt, 02_maxrnd_00.txt, 02_maxrnd_01.txt, 02_maxrnd_02.txt, 02_maxrnd_03.txt, 02_maxrnd_04.txt, 03_empty_00.txt, 03_empty_01.txt, 03_empty_02.txt
Case Name Status Exec Time Memory
00_min.txt AC 40 ms 1208 KB
00_sample_01.txt AC 26 ms 1288 KB
00_sample_02.txt AC 26 ms 1416 KB
00_sample_03.txt AC 26 ms 1212 KB
00_sample_04.txt AC 25 ms 1212 KB
00_sample_05.txt AC 25 ms 1336 KB
01_rnd_00.txt AC 23 ms 1300 KB
01_rnd_01.txt AC 25 ms 1340 KB
01_rnd_02.txt AC 24 ms 1208 KB
01_rnd_03.txt AC 25 ms 1340 KB
01_rnd_04.txt AC 24 ms 1336 KB
01_rnd_05.txt AC 25 ms 1240 KB
01_rnd_06.txt AC 24 ms 1332 KB
01_rnd_07.txt AC 25 ms 1316 KB
01_rnd_08.txt AC 24 ms 1216 KB
01_rnd_09.txt AC 26 ms 1300 KB
01_rnd_10.txt AC 25 ms 1372 KB
01_rnd_11.txt AC 25 ms 1268 KB
01_rnd_12.txt AC 26 ms 1208 KB
01_rnd_13.txt AC 25 ms 1208 KB
01_rnd_14.txt AC 25 ms 1236 KB
01_rnd_15.txt AC 24 ms 1208 KB
01_rnd_16.txt AC 25 ms 1324 KB
01_rnd_17.txt AC 25 ms 1460 KB
01_rnd_18.txt AC 25 ms 1376 KB
01_rnd_19.txt AC 25 ms 1340 KB
02_maxrnd_00.txt AC 25 ms 1416 KB
02_maxrnd_01.txt AC 25 ms 1336 KB
02_maxrnd_02.txt AC 25 ms 1416 KB
02_maxrnd_03.txt AC 25 ms 1336 KB
02_maxrnd_04.txt AC 25 ms 1464 KB
03_empty_00.txt AC 25 ms 1332 KB
03_empty_01.txt AC 25 ms 1332 KB
03_empty_02.txt AC 25 ms 1212 KB