結果

問題 No.305 鍵(2)
ユーザー LeonardoneLeonardone
提出日時 2015-12-01 12:41:50
言語 Haskell
(9.8.2)
結果
AC  
実行時間 40 ms / 2,000 ms
コード長 732 bytes
コンパイル時間 945 ms
コンパイル使用メモリ 163,512 KB
実行使用メモリ 24,408 KB
平均クエリ数 52.15
最終ジャッジ日時 2023-09-23 22:14:07
合計ジャッジ時間 2,388 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
24,024 KB
testcase_01 AC 29 ms
23,400 KB
testcase_02 AC 28 ms
24,408 KB
testcase_03 AC 29 ms
23,556 KB
testcase_04 AC 29 ms
23,388 KB
testcase_05 AC 32 ms
24,036 KB
testcase_06 AC 28 ms
23,376 KB
testcase_07 AC 30 ms
23,388 KB
testcase_08 AC 30 ms
23,652 KB
testcase_09 AC 29 ms
23,556 KB
testcase_10 AC 29 ms
23,856 KB
testcase_11 AC 29 ms
24,060 KB
testcase_12 AC 29 ms
24,048 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 #

-- yukicoder My Practice
-- author: Leonardone @ NEETSDKASU

import Control.Applicative
import System.IO
import Data.List
import Data.Char

main = solve where
    n = 10
    s0 = replicate n '0'
    solve = check n "" s0
    calc o = chr . flip o 1 . ord
    inc = calc (+)
    dec = calc (-)
    check b ys (x:xs) = switch =<< res where
        res =
            putStrLn str  >>
            hFlush stdout >>
            read . head . words <$> getLine
        str = reverse ys ++ (x:xs)
        d = dec x
        i = inc x
        switch r
            | r == n         = pure ()
            | r > b          = check n (x:ys) xs
            | r < b && b < n = check n (d:ys) xs
            | otherwise      = check r ys     (i:xs)
0