結果

問題 No.635 自然門松列
ユーザー tottoripapertottoripaper
提出日時 2018-01-20 00:39:09
言語 Haskell
(9.8.2)
結果
WA  
実行時間 -
コード長 1,370 bytes
コンパイル時間 3,253 ms
コンパイル使用メモリ 163,604 KB
実行使用メモリ 11,112 KB
最終ジャッジ日時 2023-08-26 00:36:56
合計ジャッジ時間 4,721 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,064 KB
testcase_01 AC 3 ms
6,996 KB
testcase_02 AC 3 ms
7,868 KB
testcase_03 WA -
testcase_04 AC 4 ms
7,572 KB
testcase_05 AC 7 ms
11,020 KB
testcase_06 AC 12 ms
11,056 KB
testcase_07 AC 7 ms
11,020 KB
testcase_08 AC 3 ms
7,924 KB
testcase_09 AC 3 ms
7,816 KB
testcase_10 WA -
testcase_11 AC 8 ms
11,028 KB
testcase_12 AC 7 ms
10,980 KB
testcase_13 AC 8 ms
11,004 KB
testcase_14 AC 12 ms
11,020 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 7 ms
11,112 KB
testcase_18 AC 7 ms
11,040 KB
testcase_19 AC 7 ms
11,012 KB
testcase_20 AC 7 ms
11,068 KB
testcase_21 AC 8 ms
11,100 KB
testcase_22 AC 8 ms
11,016 KB
testcase_23 AC 8 ms
10,956 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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 (replicateM)

data Length = Short | Long
  deriving (Eq)

f x y x1 y1
  | x < x1 = if y <= y1
             then (Short, (0, 10000), Long, (10000, 10000))
             else (Short, (0, t), Long, (t, 10000))
  | x == x1 = if y < y1
              then (Long, (0, 0), Short, (0, 10000))
              else if y == y1
                   then (Short, (0, 0), Long, (0, 0))
                   else (Short, (0, 0), Long, (0, 10000))
  | otherwise = if y < y1
                then (Long, (0, t), Short, (t, 10000))
                else (Long, (0, 10000), Short, (10000, 10000))
  where
    t = - (x - x1) / (y - y1)

-- [-, -)同士
intersect (x1, y1) (x2, y2) = x1 /= y1 && x2 /= y2 && not (y2 <= x1 || y1 <= x2)

infix 0 ~=>
(~=>) a b = not a || b

-- [-, -)と(-, -]
intersect' (a1, b1) (a2, b2) (x1, y1) (x2, y2) = a1 /= b1 && a2 /= b2 && not (b2 < a1 || b1 <= a2) && (a1 == b2 ~=> (x1 + y1 * a1 - x2 + y2 * a1) <= 1e-8)

main = do
  n <- readLn
  replicateM n $ do
    [x2, x1, x3, y2, y1, y3] <- fmap (map ((fromIntegral :: Int -> Double) . read) . words) getLine
    let (l1, r1, l2, r2) = f x2 y2 x1 y1
        (l1', r1', l2', r2') = f x3 y3 x1 y1
        can = if l1 == l1' then intersect r1 r1' || intersect r2 r2' else intersect' r1 r2' (x2, y2) (x3, y3) || intersect' r1' r2 (x2, y2) (x3, y3)
    putStrLn $ if can then "YES" else "NO"
0