結果
問題 | No.1020 Reverse |
ユーザー | poapoa |
提出日時 | 2020-07-30 12:06:50 |
言語 | Haskell (9.8.2) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,059 bytes |
コンパイル時間 | 6,344 ms |
コンパイル使用メモリ | 207,952 KB |
実行使用メモリ | 38,912 KB |
最終ジャッジ日時 | 2024-07-03 20:47:26 |
合計ジャッジ時間 | 7,867 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
6,812 KB |
testcase_01 | WA | - |
testcase_02 | AC | 1 ms
6,940 KB |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | AC | 63 ms
37,760 KB |
testcase_16 | AC | 66 ms
37,760 KB |
testcase_17 | WA | - |
コンパイルメッセージ
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
ソースコード
import qualified Control.Arrow as Arrow import qualified Control.Monad as Monad import qualified Data.Char as Char import qualified Data.List as List import qualified Data.ByteString.Char8 as BSC8 import qualified Data.Vector.Unboxed as VU import qualified Data.Ord as Ord getI :: BSC8.ByteString -> Maybe (Int, BSC8.ByteString) getI = fmap (Arrow.second BSC8.tail) . BSC8.readInt getAB :: IO (Int, Int) getAB = (\vec -> (vec VU.! 0, vec VU.! 1)) . VU.unfoldrN 2 getI <$> BSC8.getLine main :: IO () main = do (n, k) <- getAB s <- BSC8.unpack <$> BSC8.getLine if even (n - k) then solve' n k s else solve'' n k s solve', solve'' :: Int -> Int -> String -> IO () solve' n k s = let xs = [k, k + 1 .. n] ++ [k - 1, k - 2 .. 1] ys = zip xs s zs = List.sortBy (Ord.comparing fst) ys in putStrLn $ map snd zs solve'' n k s = let xs = [k, k + 1 .. n] ++ [1 .. k - 1] ys = zip xs s zs = List.sortBy (Ord.comparing fst) ys in putStrLn $ map snd zs