結果

問題 No.743 Segments on a Polygon
ユーザー momen999momen999
提出日時 2019-03-02 23:13:42
言語 Haskell
(9.8.2)
結果
TLE  
実行時間 -
コード長 624 bytes
コンパイル時間 5,774 ms
コンパイル使用メモリ 161,868 KB
実行使用メモリ 94,244 KB
最終ジャッジ日時 2023-09-05 17:37:37
合計ジャッジ時間 13,043 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.6.1/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )
[2 of 2] Linking a.out

ソースコード

diff #

import Control.Monad
import Data.List

rInteger :: String -> Integer
rInteger = read

solve :: [[Integer]] -> Integer
solve (_:[]) = 0
solve xs = iter (head xs) xs + solve (tail xs) where
    iter _ [] = 0
    iter x (y:ys) | c1 && c2    = 1 + iter x ys
                  | otherwise   = iter x ys
                  where
                    b1 = last x
                    c1 = b1 > head y
                    c2 = b1 < last y

main = do
    [n, m] <- map read . words <$> getLine
    ls <- sort . map (\ [x, y] -> if x > y then [y, x] else [x, y]) . map (map rInteger . words) <$> replicateM n getLine
    print $ solve ls
0