結果
| 問題 |
No.305 鍵(2)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-12-01 12:42:38 |
| 言語 | Haskell (9.10.1) |
| 結果 |
AC
|
| 実行時間 | 29 ms / 2,000 ms |
| コード長 | 732 bytes |
| コンパイル時間 | 1,969 ms |
| コンパイル使用メモリ | 173,440 KB |
| 実行使用メモリ | 25,220 KB |
| 平均クエリ数 | 52.15 |
| 最終ジャッジ日時 | 2024-07-16 21:58:28 |
| 合計ジャッジ時間 | 3,109 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 13 |
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.8.2/environments/default
[1 of 2] Compiling Main ( Main.hs, Main.o )
Main.hs:20:20: warning: [GHC-63394] [-Wx-partial]
In the use of ‘head’
(imported from Data.List, but defined in GHC.List):
"This is a partial function, it throws an error on empty lists. Use pattern matching or Data.List.uncons instead. Consider refactoring to use Data.List.NonEmpty."
|
20 | read . head . words <$> getLine
| ^^^^
[2 of 2] Linking a.out
ソースコード
-- 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) = select =<< res where
res =
putStrLn str >>
hFlush stdout >>
read . head . words <$> getLine
str = reverse ys ++ (x:xs)
d = dec x
i = inc x
select 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)