Submission #51341998


Source Code Expand

{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE FlexibleContexts #-}
{-# HLINT ignore "Use lambda-case" #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-}

module Main where

import qualified Data.List as L

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

  let n = toInteger $ length s
  let r = length (L.nub s)

  print $ if r == 1 then 1 else choose n 2 - sum [choose (toInteger (length xs)) 2 | xs <- L.group $ L.sort s, length xs >= 2]

fact :: Integer -> Integer
fact n
  | n == 0 = 1
  | n > 0 = n * fact (n - 1)
  | otherwise = error "invalid number"

choose :: Integer -> Integer -> Integer
choose n r
  | r < 0 || r > n = error "invalid arguments"
  | otherwise = fact n `div` (fact r * fact (n - r))

Submission Info

Submission Time
Task C - One Time Swap
User flowert
Language Haskell (GHC 9.4.5)
Score 0
Code Size 824 Byte
Status WA
Exec Time 2217 ms
Memory 182500 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 350
Status
AC × 2
AC × 11
WA × 1
TLE × 12
Set Name Test Cases
Sample example_00.txt, example_01.txt
All example_00.txt, example_01.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, hand_06.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt
Case Name Status Exec Time Memory
example_00.txt AC 2 ms 6452 KiB
example_01.txt AC 2 ms 6352 KiB
hand_00.txt AC 122 ms 61604 KiB
hand_01.txt AC 1 ms 6412 KiB
hand_02.txt AC 1 ms 6540 KiB
hand_03.txt AC 2 ms 6672 KiB
hand_04.txt WA 1 ms 6732 KiB
hand_05.txt TLE 2216 ms 154736 KiB
hand_06.txt TLE 2214 ms 130332 KiB
random_00.txt AC 1 ms 6668 KiB
random_01.txt AC 1 ms 6480 KiB
random_02.txt AC 2 ms 6396 KiB
random_03.txt AC 2 ms 6760 KiB
random_04.txt AC 2 ms 6524 KiB
random_05.txt TLE 2217 ms 182340 KiB
random_06.txt TLE 2217 ms 181436 KiB
random_07.txt TLE 2217 ms 181432 KiB
random_08.txt TLE 2217 ms 181368 KiB
random_09.txt TLE 2217 ms 181392 KiB
random_10.txt TLE 2217 ms 181532 KiB
random_11.txt TLE 2217 ms 181368 KiB
random_12.txt TLE 2217 ms 181368 KiB
random_13.txt TLE 2217 ms 181472 KiB
random_14.txt TLE 2217 ms 182500 KiB