提出 #73724228


ソースコード 拡げる

{-# 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 -> String -> Int
f c [] = 0
f c (s:ss) = if c == s then 1 + ( f c ss ) else f c ss
g' :: Char -> String -> String
g' c [] = []
g' c (s:ss)
    | c == s = g' c ss
    | otherwise = s:(g' c ss)
g :: Int -> [Int] -> String -> String -> String
g m [] _ s = s
g m l t s
    | m == head l = g m (tail l) (tail t) (g' (head t) s)
    | otherwise = g m (tail l) (tail t) s
main = do
    s <- getLine
    let l = (flip f s) <$> ['a'..'z']
    let m = maximum l
    -- print m
    putStrLn $ g m l ['a'..'z'] s

提出情報

提出日時
問題 B - mpp
ユーザ suisankafe2
言語 Haskell (GHC 9.8.4)
得点 200
コード長 845 Byte
結果 AC
実行時間 16 ms
メモリ 8232 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 [] = 0
   |   ^

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

app/Main.hs:19:3: warning: [GHC-40910] [-Wunused-matches]
    Defined but not used: ‘m’
   |
19 | g m [] _ s = s
   |   ^

app/Main.hs:21:12: 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."
   |
21 |     | m == head l = g m (tail l) (tail t) (g' (head t) s)
   |            ^^^^

app/Main.hs:21: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."
   |
21 |     | m == head l = g m (tail l) (tail t) (g' (head t) s)
   |                          ^^^^

app/Main.hs:21: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."
   |
21 |     | m == head l = g m (tail l) (tail t) (g' (head t) s)
   |                                   ^^^^

app/Main.hs:21:48: 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."
   |
21 |     | m == head l = g m (tail l) (tail t) (g' (head t) s)
   |                                                ^^^^

app/Main.hs:22:24: 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."
   |
22 |     | otherwise = g m (tail l) (tail t) s
   |                        ^^^^

app/Main.hs:22:33: 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."
   |
22 |     | otherwise = g m (tail l) (tail t) s
   |                                 ^^^^

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

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 200 / 200
結果
AC × 3
AC × 20
セット名 テストケース
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
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 16 ms 7860 KiB
00_sample_01.txt AC 3 ms 7844 KiB
00_sample_02.txt AC 3 ms 7956 KiB
01_test_00.txt AC 3 ms 7996 KiB
01_test_01.txt AC 3 ms 7940 KiB
01_test_02.txt AC 3 ms 7976 KiB
01_test_03.txt AC 3 ms 8000 KiB
01_test_04.txt AC 3 ms 7972 KiB
01_test_05.txt AC 3 ms 7736 KiB
01_test_06.txt AC 3 ms 8056 KiB
01_test_07.txt AC 3 ms 8100 KiB
01_test_08.txt AC 3 ms 7996 KiB
01_test_09.txt AC 3 ms 7972 KiB
01_test_10.txt AC 3 ms 8032 KiB
01_test_11.txt AC 3 ms 7884 KiB
01_test_12.txt AC 3 ms 8024 KiB
01_test_13.txt AC 3 ms 8084 KiB
01_test_14.txt AC 3 ms 8232 KiB
01_test_15.txt AC 3 ms 7972 KiB
01_test_16.txt AC 3 ms 8228 KiB