提出 #49477966


ソースコード 拡げる

{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE ViewPatterns #-}

module Main where

import qualified Control.Applicative
import Control.Monad
import qualified Control.Monad
import Control.Monad.ST
import Control.Monad.State
import Data.Array.IArray
import qualified Data.ByteString.Char8 as BS
import Data.Char (GeneralCategory (Control), digitToInt, isSpace, readLitChar)
import qualified Data.IntSet as IntSet
import Data.Ix
import qualified Data.List as L
import Data.Maybe (catMaybes, fromJust, maybeToList)
import qualified Data.Sequence as Seq
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import Debug.Trace (traceShow, traceShowId)

main :: IO ()
main = do
  s <- BS.getLine

  putStrLn $ judge $ BS.group s

judge :: [BS.ByteString] -> String
judge g
  | null g = "Yes"
  | length g == 1 = if isPrefixOfA (head g) || isPrefixOfB (head g) || isPrefixOfC (head g) then "Yes" else "No"
  | length g == 2 = if isPrefixOfA (head g) && isPrefixOfB (g !! 1) || isPrefixOfB (head g) && isPrefixOfC (g !! 1) then "Yes" else "No"
  | length g == 3 = if isPrefixOfA (head g) && isPrefixOfB (g !! 1) && isPrefixOfC (g !! 2) then "Yes" else "No"
  | otherwise = "No"
  where
    isPrefixOfA = BS.isPrefixOf (BS.pack "A")
    isPrefixOfB = BS.isPrefixOf (BS.pack "B")
    isPrefixOfC = BS.isPrefixOf (BS.pack "C")

{- Library -}
readInt :: IO Int
readInt = readLn

readInputIntList :: IO [Int]
readInputIntList = L.unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

readPairInt :: IO (Int, Int)
readPairInt = (\[a, b] -> (a, b)) . parseLineIntList <$> BS.getLine

readIntPairIntLineV :: Int -> IO (V.Vector (Int, Int))
readIntPairIntLineV n = V.fromList <$> replicateM n readPairInt

readIntPairIntLineVU :: Int -> IO (VU.Vector (Int, Int))
readIntPairIntLineVU n = VU.fromList <$> replicateM n readPairInt

parseLineIntList :: BS.ByteString -> [Int]
parseLineIntList = L.unfoldr (BS.readInt . BS.dropWhile isSpace)

readTuple :: String -> (String, Int)
readTuple input = (str, read num :: Int)
  where
    [str, num] = words input

withInTime :: Int -> Int -> Bool
withInTime start time
  | start <= end = time >= start && time < end
  | otherwise = time >= start || time < end
  where
    end = (start + 9) `mod` 24

readGrid :: Int -> IO (V.Vector (V.Vector Char))
readGrid n = V.fromList <$> replicateM n (V.fromList <$> getLine)

trisect :: (Int, Int) -> (Int -> Int) -> (Int, Int)
trisect (l, r) f
  | r - l <= 2 = (l, r)
  | f m1 > f m2 = trisect (m1, r) f
  | otherwise = trisect (l, m2) f
  where
    m1 = (l * 2 + r) `div` 3
    m2 = (l + r * 2) `div` 3

binarySearch :: (Ord t2, IArray a t2, Ix t1, Integral t1) => a t1 t2 -> t2 -> t1 -> t1 -> t1
binarySearch arr val low high
  | high < low = low
  | otherwise =
      let mid = low + (high - low) `div` 2
       in if arr ! mid <= val
            then binarySearch arr val (mid + 1) high
            else binarySearch arr val low (mid - 1)

isPrime :: Int -> Bool
isPrime x = all (\n -> x `mod` n /= 0) lst
  where
    xSqrt = floor (sqrt $ fromIntegral x :: Double) :: Int
    lst = [2 .. xSqrt]

sieve :: Int -> IntSet.IntSet
sieve n = go 2 (IntSet.fromList [2 .. n])
  where
    go p s
      | p * p > n = s
      | otherwise = go (p + 1) (IntSet.difference s (IntSet.fromList [p * p, p * p + p .. n]))

提出情報

提出日時
問題 B - Extended ABC
ユーザ flowert
言語 Haskell (GHC 9.4.5)
得点 0
コード長 3595 Byte
結果 WA
実行時間 1 ms
メモリ 7072 KiB

コンパイルエラー

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

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

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

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

app/Main.hs:19:1: warning: [-Wunused-imports]
    The import of ‘Control, GeneralCategory, digitToInt, readLitChar’
    from module ‘Data.Char’ is redundant
   |
19 | import Data.Char (GeneralCategory (Control), digitToInt, isSpace, readLitChar)
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

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

app/Main.hs:23:1: warning: [-Wunused-imports]
    The import of ‘Data.Maybe’ is redundant
      except perhaps to import instances from ‘Data.Maybe’
    To import instances alone, use: import Data.Maybe()
   |
23 | import Data.Maybe (catMaybes, fromJust, maybeToList)
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

app/Main.hs:24:1: warning: [-Wunused-imports]
    The qualified import of ‘Data.Sequence’ is redundant
      except perhaps to import instances from ‘Data.Sequence’
    To import instances alone, use: import Data.Sequence()
   |
24 | import qualified Data.Sequence as Seq
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

app/Main.hs:27:1: warning: [-Wunused-imports]
    The import of ‘Debug.Trace’ is redundant
      except perhaps to import instances from ‘Debug.Trace’
    To import instances alone, use: import Debug.Trace()
   |
27 | import Debug.Trace (traceShow, traceShowId)
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

app/Main.hs:55:16: warning: [-Wincomplete-uni-patterns]
    Pattern match(es) are non-exhaustive
    In a lambda abstraction:
        Patterns of type ‘[Int]’ not matched:
            []
            [_]
            (_:_:_:_)
   |
55 | readPairInt = (\[a, b] -> (a, b)) . parseLineIntList <$> BS.getLine
   |                ^^^^^^^^^^^^^^^^^

app/Main.hs:69:5: warning: [-Wincomplete-uni-patterns]
    Pattern match(es) are non-exhaustive
    In a pattern binding:
        Patterns of type ‘[String]’ not matched:
            []
            [_]
            (_:_:_:_)
   |
69 |     [str, num] = words input
   |     ^^^^^^^^^^^^^^^^^^^^^^^^

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 0 / 200
結果
AC × 4
AC × 32
WA × 1
セット名 テストケース
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 01_handmade_04.txt, 01_handmade_05.txt, 01_handmade_06.txt, 01_handmade_07.txt, 01_handmade_08.txt, 01_handmade_09.txt, 01_handmade_10.txt, 01_handmade_11.txt, 01_handmade_12.txt, 01_handmade_13.txt, 02_random_07.txt, 02_random_08.txt, 02_random_09.txt, 02_random_10.txt, 02_random_11.txt, 02_random_12.txt, 02_random_13.txt, 02_random_14.txt, 02_random_15.txt, 02_random_16.txt, 02_random_17.txt, 02_random_18.txt, 02_random_19.txt, 02_random_20.txt, 02_random_21.txt, 02_random_22.txt, 02_random_23.txt, 02_random_24.txt, 02_random_25.txt
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 1 ms 7020 KiB
00_sample_01.txt AC 1 ms 7016 KiB
00_sample_02.txt AC 1 ms 6796 KiB
00_sample_03.txt AC 1 ms 7024 KiB
01_handmade_04.txt AC 1 ms 7000 KiB
01_handmade_05.txt AC 1 ms 7060 KiB
01_handmade_06.txt AC 1 ms 7028 KiB
01_handmade_07.txt AC 1 ms 6920 KiB
01_handmade_08.txt AC 1 ms 7024 KiB
01_handmade_09.txt AC 1 ms 7060 KiB
01_handmade_10.txt AC 1 ms 7052 KiB
01_handmade_11.txt WA 1 ms 7016 KiB
01_handmade_12.txt AC 1 ms 6928 KiB
01_handmade_13.txt AC 1 ms 6972 KiB
02_random_07.txt AC 1 ms 6796 KiB
02_random_08.txt AC 1 ms 7012 KiB
02_random_09.txt AC 1 ms 7060 KiB
02_random_10.txt AC 1 ms 6964 KiB
02_random_11.txt AC 1 ms 6972 KiB
02_random_12.txt AC 1 ms 7040 KiB
02_random_13.txt AC 1 ms 7012 KiB
02_random_14.txt AC 1 ms 6956 KiB
02_random_15.txt AC 1 ms 7060 KiB
02_random_16.txt AC 1 ms 7072 KiB
02_random_17.txt AC 1 ms 7056 KiB
02_random_18.txt AC 1 ms 6964 KiB
02_random_19.txt AC 1 ms 7060 KiB
02_random_20.txt AC 1 ms 6800 KiB
02_random_21.txt AC 1 ms 6924 KiB
02_random_22.txt AC 1 ms 6788 KiB
02_random_23.txt AC 1 ms 7068 KiB
02_random_24.txt AC 1 ms 7064 KiB
02_random_25.txt AC 1 ms 6792 KiB