Submission #308776


Source Code Expand

import Control.Applicative
import Data.List

main = do
  str <- getContents
  let times = tail $ lines str
  let pairs = sortBy sf $ map mkpair times
  print_loop $ sortBy sf $ loop pairs []

mkpair str = (normalize (kirisage st),  normalize (kiriage ed))
  where
    [st, ed] = map read $ [take 4 str, drop 5 str]

normalize n =
  if drop 2 (show n) == "60" then n - 60 + 100
  else n

kiriage n =
  if n `mod` 5 == 0 then n
  else n + (5 - n `mod` 5)

kirisage n =
  if n `mod` 5 == 0 then n
  else n - (n `mod` 5)

myprint n =
  putStr $ replicate (4 - length s) '0' ++ s
  where s = show n

loop [] acc = acc
loop ((st, ed) : rest) acc =
  loop rest (update st ed acc)
  
update st ed acc = f r
  where r = find (\(a, b) -> st <= b) acc
        f Nothing = acc ++ [(st,ed)]
        f (Just (a,b)) = sortBy sf $ (min a st, max b ed) : delete (a,b) acc

print_loop [] = return ()
print_loop ((st, ed) : rest) = do
  myprint st
  putStr "-"
  myprint ed
  putStrLn ""
  print_loop rest

sf (a, _) (b, _)
  | a < b = LT
  | a > b = GT
  | otherwise = EQ

Submission Info

Submission Time
Task D - 感雨時刻の整理
User lambdataro
Language Haskell (GHC 7.4.1)
Score 0
Code Size 1104 Byte
Status WA
Exec Time 886 ms
Memory 25640 KB

Judge Result

Set Name all
Score / Max Score 0 / 100
Status
AC × 40
WA × 8
Set Name Test Cases
all 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, cho_cho_chokudai.txt, chokudai_ga_cho.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt, test_16.txt, test_17.txt, test_18.txt, test_19.txt, test_20.txt, test_21.txt, test_22.txt, test_23.txt, test_24.txt, test_25.txt, test_26.txt, test_27.txt, test_28.txt, test_29.txt, test_30.txt, test_31.txt, test_32.txt, test_33.txt, test_34.txt, test_35.txt, test_36.txt, test_37.txt, test_38.txt, test_39.txt, test_40.txt, test_41.txt, test_42.txt, test_43.txt
Case Name Status Exec Time Memory
00_sample_01.txt AC 42 ms 1184 KB
00_sample_02.txt AC 25 ms 1172 KB
00_sample_03.txt AC 27 ms 1256 KB
cho_cho_chokudai.txt AC 609 ms 16352 KB
chokudai_ga_cho.txt AC 658 ms 23600 KB
test_01.txt AC 31 ms 1672 KB
test_02.txt AC 31 ms 1736 KB
test_03.txt AC 32 ms 1744 KB
test_04.txt AC 29 ms 1676 KB
test_05.txt AC 31 ms 1620 KB
test_06.txt AC 31 ms 1792 KB
test_07.txt AC 31 ms 1760 KB
test_08.txt AC 31 ms 1732 KB
test_09.txt AC 40 ms 2096 KB
test_10.txt AC 41 ms 2192 KB
test_11.txt AC 41 ms 2080 KB
test_12.txt AC 35 ms 2036 KB
test_13.txt AC 32 ms 1688 KB
test_14.txt AC 40 ms 2060 KB
test_15.txt AC 44 ms 2160 KB
test_16.txt AC 32 ms 1676 KB
test_17.txt AC 39 ms 2108 KB
test_18.txt AC 30 ms 1824 KB
test_19.txt AC 37 ms 1936 KB
test_20.txt AC 37 ms 2064 KB
test_21.txt AC 770 ms 25624 KB
test_22.txt AC 772 ms 25616 KB
test_23.txt AC 785 ms 25616 KB
test_24.txt AC 792 ms 25508 KB
test_25.txt AC 773 ms 25556 KB
test_26.txt WA 839 ms 25508 KB
test_27.txt AC 690 ms 23460 KB
test_28.txt WA 834 ms 25616 KB
test_29.txt AC 31 ms 1128 KB
test_30.txt WA 34 ms 1676 KB
test_31.txt WA 146 ms 5128 KB
test_32.txt AC 30 ms 1668 KB
test_33.txt WA 567 ms 18380 KB
test_34.txt AC 29 ms 1168 KB
test_35.txt AC 35 ms 1804 KB
test_36.txt AC 777 ms 25556 KB
test_37.txt WA 886 ms 25504 KB
test_38.txt WA 820 ms 25640 KB
test_39.txt AC 805 ms 24612 KB
test_40.txt WA 796 ms 24512 KB
test_41.txt AC 629 ms 20612 KB
test_42.txt AC 765 ms 25616 KB
test_43.txt AC 648 ms 23488 KB