結果

問題 No.550 夏休みの思い出(1)
ユーザー tottoripapertottoripaper
提出日時 2017-07-28 23:42:45
言語 Haskell
(9.8.2)
結果
RE  
実行時間 -
コード長 1,209 bytes
コンパイル時間 4,374 ms
コンパイル使用メモリ 169,856 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-18 12:20:41
合計ジャッジ時間 2,784 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 AC 2 ms
5,376 KB
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 AC 2 ms
5,376 KB
testcase_09 RE -
testcase_10 RE -
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 RE -
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 1 ms
5,376 KB
testcase_18 RE -
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 1 ms
5,376 KB
testcase_21 AC 1 ms
5,376 KB
testcase_22 RE -
testcase_23 AC 2 ms
5,376 KB
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 AC 1 ms
5,376 KB
testcase_29 RE -
testcase_30 RE -
testcase_31 AC 1 ms
5,376 KB
testcase_32 AC 2 ms
5,376 KB
testcase_33 RE -
testcase_34 AC 1 ms
5,376 KB
testcase_35 RE -
testcase_36 RE -
testcase_37 AC 1 ms
5,376 KB
testcase_38 RE -
testcase_39 AC 2 ms
5,376 KB
testcase_40 AC 1 ms
5,376 KB
testcase_41 AC 1 ms
5,376 KB
testcase_42 RE -
testcase_43 AC 1 ms
5,376 KB
testcase_44 RE -
testcase_45 RE -
testcase_46 AC 2 ms
5,376 KB
testcase_47 RE -
testcase_48 RE -
testcase_49 AC 1 ms
5,376 KB
testcase_50 AC 1 ms
5,376 KB
testcase_51 AC 2 ms
5,376 KB
testcase_52 RE -
testcase_53 RE -
testcase_54 RE -
testcase_55 RE -
testcase_56 AC 2 ms
5,376 KB
testcase_57 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.8.2/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )
[2 of 2] Linking a.out

ソースコード

diff #

import Data.List (sort)

readMany :: (Read a) => IO [a]
readMany = fmap (map read . words) getLine

solve :: (Integer -> Integer) -> Integer -> Integer -> Integer
solve f l r
  | l == r = 10^9
  | abs (r - l) == 1 = l
  | f mid > 0 = solve f l mid
  | otherwise = solve f mid r
  where
    mid = (l + r) `div` 2

isValid f x = f x == 0

main = do
  [a, b, c] <- readMany
  let x0 = solve f (-10^12) (10^12)
      x1 = solve f (-10^12) x0
      x2 = solve f (x0 + 1) (10^12)
      f x = x^3 + a * x^2 + b * x + c
      l = sort $ case (isValid f x1, isValid f x2, x1 /= x2) of
        (True, True, True) -> [x0, x1, x2]
        (True, _, _) -> let [x0', x1'] = sort [x0, x1]
                            x2' = solve f (x1' - 1) x0'
                            x3' = solve f (-10^12) x0'
                        in [x0', x1', if isValid f x2' then x2' else x3']
        (False, True, _) -> let [x0', x1'] = sort [x0, x2]
                                x2' = solve f (x1' - 1) x0'
                                x3' = solve f (x1' + 1) (10^12)
                            in [x0', x1', if isValid f x2' then x2' else x3']
        otherwise -> undefined
  -- print [x0, x1, x2]
  putStrLn $ unwords $ map show l
0