結果

問題 No.488 四角関係
ユーザー alpha_virginisalpha_virginis
提出日時 2017-02-24 23:03:48
言語 Haskell
(9.8.2)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,373 bytes
コンパイル時間 185 ms
コンパイル使用メモリ 143,660 KB
最終ジャッジ日時 2023-10-20 22:39:15
合計ジャッジ時間 868 ms
ジャッジサーバーID
(参考情報)
judge10 / judge11
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.6.2/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )

Main.hs:5:1: error:
    Could not load module ‘Data.ByteString.Char8’
    It is a member of the hidden package ‘bytestring-0.11.4.0’.
    You can run ‘:set -package bytestring’ to expose it.
    (Note: this unloads all the modules in the current scope.)
    Use -v (or `:set -v` in ghci) to see a list of the files searched for.
  |
5 | import qualified Data.ByteString.Char8 as C
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Main.hs:12:1: error:
    Could not load module ‘Data.IntMap’
    It is a member of the hidden package ‘containers-0.6.7’.
    You can run ‘:set -package containers’ to expose it.
    (Note: this unloads all the modules in the current scope.)
    Use -v (or `:set -v` in ghci) to see a list of the files searched for.
   |
12 | import qualified Data.IntMap as IntMap
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Main.hs:13:1: error:
    Could not load module ‘Data.Map’
    It is a member of the hidden package ‘containers-0.6.7’.
    You can run ‘:set -package containers’ to expose it.
    (Note: this unloads all the modules in the current scope.)
    Use -v (or `:set -v` in ghci) to see a list of the files searched for.
   |
13 | import qualified Data.Map as Map
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

ソースコード

diff #

{-# LANGUAGE OverloadedStrings #-}
module Main where

import Data.Maybe
import qualified Data.ByteString.Char8 as C
import Control.Monad(forM_)
import Data.Int
import Data.List
import Data.Array
import Data.Word
import Data.Bits
import qualified Data.IntMap as IntMap
import qualified Data.Map as Map
import Data.Functor
import Data.Tuple

yes :: C.ByteString
yes = "YES"

no :: C.ByteString
no = "NO"

getInts :: IO [Int]
getInts = do
  ss <- C.getLine
  return $ map (fst . fromJust . C.readInt) $ C.words ss

getIntss :: Int -> IO [[Int]]
getIntss 0 = return []
getIntss n = do
  xs <- getInts
  xss <- getIntss (n - 1)  
  return $ xs : xss

-- end standard template --

toPair :: [a] -> (a,a)
toPair xs = ((xs !! 0), (xs !! 1))

main :: IO ()
main = do
  [n,m] <- getInts
  xss <- getIntss m
  let res = solve n m xss
  print res

solve :: Int -> Int -> [[Int]] -> Int
solve n m xss = res
  where
    as = accumArray (||) False ((0,0),(n-1,n-1)) $ zip ((toPair <$> xss) ++ (swap.toPair <$> xss)) (repeat True)
    ys = [f n1 n2 n3 n4 | n1 <- ts, n2 <- ts, n3 <- ts, n4 <- ts]
    ts = [0..n-1]
    f :: Int -> Int -> Int -> Int -> Bool
    f n1 n2 n3 n4 = as ! (n1, n2) && as ! (n2, n3) && as ! (n3, n4) && as ! (n4, n1) &&
                    not (as ! (n1, n3)) && not (as ! (n2, n4)) && n1 /= n3 && n2 /= n4
    t = length $ filter (==True) ys
    res = t `div` 8

0