提出 #73716084


ソースコード 拡げる

{-# LANGUAGE BangPatterns #-}
import           Control.Monad
import qualified Data.ByteString.Char8 as BS
import           Data.Maybe
import           Data.List
readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
f :: Char -> Int -> String -> [Int]
f c _ [] = []
f c n s = if head s == c then (n : f c (n+1) (tail s) ) else f c (n+1) (tail s)
g :: [Int] -> [Int] -> [Int] -> Int
g [] b c = 0
g _ [] c = 0
g _ b [] = 0
g a b c 
    | head a > head b = g a (tail b) c
    | head b > head c = g a b (tail c)
    | otherwise = 1 + g (tail a) (tail b) (tail c)
main = do
    s <- getLine
    let al = f 'A' 0 s
    let bl = f 'B' 0 s
    let cl = f 'C' 0 s
    -- print al
    print $ g al bl cl

提出情報

提出日時
問題 D - Take ABC 2
ユーザ suisankafe2
言語 Haskell (GHC 9.8.4)
得点 400
コード長 813 Byte
結果 AC
実行時間 115 ms
メモリ 81920 KiB

コンパイルエラー

Configuration is affected by the following files:
- cabal.project
- cabal.project.freeze
- cabal.project.local

app/Main.hs:2:1: warning: [GHC-66111] [-Wunused-imports]
    The import of ‘Control.Monad’ is redundant
      except perhaps to import instances from ‘Control.Monad’
    To import instances alone, use: import Control.Monad()
  |
2 | import           Control.Monad
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

app/Main.hs:5:1: warning: [GHC-66111] [-Wunused-imports]
    The import of ‘Data.List’ is redundant
      except perhaps to import instances from ‘Data.List’
    To import instances alone, use: import Data.List()
  |
5 | import           Data.List
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^

app/Main.hs:6:1: warning: [GHC-38417] [-Wmissing-signatures]
    Top-level binding with no type signature:
      readInt :: BS.ByteString -> Int
  |
6 | readInt = fst . fromJust . BS.readInt
  | ^^^^^^^

app/Main.hs:6:1: warning: [GHC-40910] [-Wunused-top-binds]
    Defined but not used: ‘readInt’
  |
6 | readInt = fst . fromJust . BS.readInt
  | ^^^^^^^

app/Main.hs:7:1: warning: [GHC-38417] [-Wmissing-signatures]
    Top-level binding with no type signature:
      readIntList :: BS.ByteString -> [Int]
  |
7 | readIntList = map readInt . BS.words
  | ^^^^^^^^^^^

app/Main.hs:7:1: warning: [GHC-40910] [-Wunused-top-binds]
    Defined but not used: ‘readIntList’
  |
7 | readIntList = map readInt . BS.words
  | ^^^^^^^^^^^

app/Main.hs:8:1: warning: [GHC-38417] [-Wmissing-signatures]
    Top-level binding with no type signature: getInt :: IO Int
  |
8 | getInt = readInt <$> BS.getLine
  | ^^^^^^

app/Main.hs:8:1: warning: [GHC-40910] [-Wunused-top-binds]
    Defined but not used: ‘getInt’
  |
8 | getInt = readInt <$> BS.getLine
  | ^^^^^^

app/Main.hs:9:1: warning: [GHC-38417] [-Wmissing-signatures]
    Top-level binding with no type signature: getIntList :: IO [Int]
  |
9 | getIntList = readIntList <$> BS.getLine
  | ^^^^^^^^^^

app/Main.hs:9:1: warning: [GHC-40910] [-Wunused-top-binds]
    Defined but not used: ‘getIntList’
  |
9 | getIntList = readIntList <$> BS.getLine
  | ^^^^^^^^^^

app/Main.hs:11:3: warning: [GHC-40910] [-Wunused-matches]
    Defined but not used: ‘c’
   |
11 | f c _ [] = []
   |   ^

app/Main.hs:12:14: 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."
   |
12 | f c n s = if head s == c then (n : f c (n+1) (tail s) ) else f c (n+1) (tail s)
   |              ^^^^

app/Main.hs:12:47: warning: [GHC-63394] [-Wx-partial]
    In the use of ‘tail’
    (imported from Data.List, but defined in GHC.List):
    "This is a partial function, it throws an error on empty lists. Replace it with drop 1, or use pattern matching or Data.List.uncons instead. Consider refactoring to use Data.List.NonEmpty."
   |
12 | f c n s = if head s == c then (n : f c (n+1) (tail s) ) else f c (n+1) (tail s)
   |                                               ^^^^

app/Main.hs:12:73: warning: [GHC-63394] [-Wx-partial]
    In the use of ‘tail’
    (imported from Data.List, but defined in GHC.List):
    "This is a partial function, it throws an error on empty lists. Replace it with drop 1, or use pattern matching or Data.List.uncons instead. Consider refactoring to use Data.List.NonEmpty."
   |
12 | f c n s = if head s == c then (n : f c (n+1) (tail s) ) else f c (n+1) (tail s)
   |                                                                         ^^^^

app/Main.hs:14:6: warning: [GHC-40910] [-Wunused-matches]
    Defined but not used: ‘b’
   |
14 | g [] b c = 0
   |      ^

app/Main.hs:14:8: warning: [GHC-40910] [-Wunused-matches]
    Defined but not used: ‘c’
   |
14 | g [] b c = 0
   |        ^

app/Main.hs:15:8: warning: [GHC-40910] [-Wunused-matches]
    Defined but not used: ‘c’
   |
15 | g _ [] c = 0
   |        ^

app/Main.hs:16:5: warning: [GHC-40910] [-Wunused-matches]
    Defined but not used: ‘b’
   |
16 | g _ b [] = 0
   |     ^

app/Main.hs:18:7: 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."
   |
18 |     | head a > head b = g a (tail b) c
   |       ^^^^

app/Main.hs:18:16: 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."
   |
18 |     | head a > head b = g a (tail b) c
   |                ^^^^

app/Main.hs:18:30: warning: [GHC-63394] [-Wx-partial]
    In the use of ‘tail’
    (imported from Data.List, but defined in GHC.List):
    "This is a partial function, it throws an error on empty lists. Replace it with drop 1, or use pattern matching or Data.List.uncons instead. Consider refactoring to use Data.List.NonEmpty."
   |
18 |     | head a > head b = g a (tail b) c
   |                              ^^^^

app/Main.hs:19:7: 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."
   |
19 |     | head b > head c = g a b (tail c)
   |       ^^^^

app/Main.hs:19:16: 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."
   |
19 |     | head b > head c = g a b (tail c)
   |                ^^^^

app/Main.hs:19:32: warning: [GHC-63394] [-Wx-partial]
    In the use of ‘tail’
    (imported from Data.List, but defined in GHC.List):
    "This is a partial function, it throws an error on empty lists. Replace it with drop 1, or use pattern matching or Data.List.uncons instead. Consider refactoring to use Data.List.NonEmpty."
   |
19 |     | head b > head c = g a b (tail c)
   |                                ^^^^

app/Main.hs:20:26: warning: [GHC-63394] [-Wx-partial]
    In the use of ‘tail’
    (imported from Data.List, but defined in GHC.List):
    "This is a partial function, it throws an error on empty lists. Replace it with drop 1, or use pattern matching or Data.List.uncons instead. Consider refactoring to use Data.List.NonEmpty."
   |
20 |     | otherwise = 1 + g (tail a) (tail b) (tail c)
   |                          ^^^^

app/Main.hs:20:35: warning: [GHC-63394] [-Wx-partial]
    In the use of ‘tail’
    (imported from Data.List, but defined in GHC.List):
    "This is a partial function, it throws an error on empty lists. Replace it with drop 1, or use pattern matching or Data.List.uncons instead. Consider refactoring to use Data.List.NonEmpty."
   |
20 |     | otherwise = 1 + g (tail a) (tail b) (tail c)
   |                                   ^^^^

app/Main.hs:20:44: warning: [GHC-63394] [-Wx-partial]
    In the use of ‘tail’
    (imported from Data.List, but defined in GHC.List):
    "This is a partial function, it throws an error on empty lists. Replace it with drop 1, or use pattern matching or Data.List.uncons instead. Consider refactoring to use Data.List.NonEmpty."
   |
20 |     | otherwise = 1 + g (tail a) (tail b) (tail c)
   |                                            ^^^^

app/Main.hs:21:1: warning: [GHC-38417] [-Wmissing-signatures]
    Top-level binding with no type signature: main :: IO ()
   |
21 | main = do
   | ^^^^
Configuration is affected by the following files:
- cabal.project
- cabal.project.freeze
- cabal.project.local

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 400 / 400
結果
AC × 3
AC × 35
セット名 テストケース
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_test_00.txt, 01_test_01.txt, 01_test_02.txt, 01_test_03.txt, 01_test_04.txt, 01_test_05.txt, 01_test_06.txt, 01_test_07.txt, 01_test_08.txt, 01_test_09.txt, 01_test_10.txt, 01_test_11.txt, 01_test_12.txt, 01_test_13.txt, 01_test_14.txt, 01_test_15.txt, 01_test_16.txt, 01_test_17.txt, 01_test_18.txt, 01_test_19.txt, 01_test_20.txt, 01_test_21.txt, 01_test_22.txt, 01_test_23.txt, 01_test_24.txt, 01_test_25.txt, 01_test_26.txt, 02_corner_00.txt, 02_corner_01.txt, 02_corner_02.txt, 02_corner_03.txt, 02_corner_04.txt
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 18 ms 7896 KiB
00_sample_01.txt AC 2 ms 7936 KiB
00_sample_02.txt AC 2 ms 7952 KiB
01_test_00.txt AC 2 ms 7952 KiB
01_test_01.txt AC 2 ms 8044 KiB
01_test_02.txt AC 2 ms 7996 KiB
01_test_03.txt AC 70 ms 39628 KiB
01_test_04.txt AC 56 ms 39688 KiB
01_test_05.txt AC 66 ms 39872 KiB
01_test_06.txt AC 96 ms 53392 KiB
01_test_07.txt AC 95 ms 53568 KiB
01_test_08.txt AC 89 ms 53820 KiB
01_test_09.txt AC 87 ms 53324 KiB
01_test_10.txt AC 87 ms 53824 KiB
01_test_11.txt AC 89 ms 53376 KiB
01_test_12.txt AC 88 ms 53836 KiB
01_test_13.txt AC 90 ms 53184 KiB
01_test_14.txt AC 99 ms 73500 KiB
01_test_15.txt AC 97 ms 73536 KiB
01_test_16.txt AC 95 ms 73428 KiB
01_test_17.txt AC 87 ms 50760 KiB
01_test_18.txt AC 71 ms 51804 KiB
01_test_19.txt AC 88 ms 52904 KiB
01_test_20.txt AC 81 ms 49756 KiB
01_test_21.txt AC 87 ms 52820 KiB
01_test_22.txt AC 73 ms 50740 KiB
01_test_23.txt AC 84 ms 49716 KiB
01_test_24.txt AC 78 ms 49872 KiB
01_test_25.txt AC 78 ms 48952 KiB
01_test_26.txt AC 77 ms 49756 KiB
02_corner_00.txt AC 71 ms 53364 KiB
02_corner_01.txt AC 115 ms 81920 KiB
02_corner_02.txt AC 80 ms 62968 KiB
02_corner_03.txt AC 77 ms 63096 KiB
02_corner_04.txt AC 79 ms 63036 KiB