提出 #69664382
ソースコード 拡げる
{-# OPTIONS_GHC -Wall #-} {-# OPTIONS_GHC -Wname-shadowing #-} -- 内側のスコープの値と同じ名前が外側のスコープにあるとき警告する import Control.Monad import qualified Data.ByteString.Char8 as BS import Data.Char import Data.List readInts :: IO [Int] readInts = unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine main :: IO () main = do n <- readLn :: IO Int as <- readInts let bs = zip as [1..] let cs = map fst $ filter ((/=(-1)).fst) bs let ds = [1..n] \\ cs let cands = solve ds as if any (==(-1)) cands then do putStrLn "No" else do putStrLn "Yes" putStrLn $ unwords $ map show cands solve :: [Int] -> [Int] -> [Int] solve [] [] = [] solve [] (a:as) | a /= (-1) = a : solve [] as | otherwise = [-1] solve dds@(d:ds) [] = [-1] solve dds@(d:ds) (a:as) | a == (-1) = d : solve ds as | otherwise = a : solve dds as
提出情報
提出日時 | |
---|---|
問題 | B - Find Permutation 2 |
ユーザ | haskboy |
言語 | Haskell (GHC 9.4.5) |
得点 | 200 |
コード長 | 928 Byte |
結果 | AC |
実行時間 | 2 ms |
メモリ | 7140 KiB |
コンパイルエラー
app/Main.hs:4:1: warning: [-Wunused-imports] The import of ‘Control.Monad’ is redundant except perhaps to import instances from ‘Control.Monad’ To import instances alone, use: import Control.Monad() | 4 | import Control.Monad | ^^^^^^^^^^^^^^^^^^^^ app/Main.hs:16:20: warning: [-Wtype-defaults] • Defaulting the type variable ‘b0’ to type ‘Integer’ in the following constraints (Num b0) arising from the literal ‘1’ at app/Main.hs:16:20 (Enum b0) arising from the arithmetic sequence ‘1 .. ’ at app/Main.hs:16:19-23 • In the expression: 1 In the second argument of ‘zip’, namely ‘[1 .. ]’ In the expression: zip as [1 .. ] | 16 | let bs = zip as [1..] | ^ app/Main.hs:31:7: warning: [-Wunused-matches] Defined but not used: ‘dds’ | 31 | solve dds@(d:ds) [] = [-1] | ^^^ app/Main.hs:31:12: warning: [-Wunused-matches] Defined but not used: ‘d’ | 31 | solve dds@(d:ds) [] = [-1] | ^ app/Main.hs:31:14: warning: [-Wunused-matches] Defined but not used: ‘ds’ | 31 | solve dds@(d:ds) [] = [-1] | ^^
ジャッジ結果
セット名 | Sample | All | ||||
---|---|---|---|---|---|---|
得点 / 配点 | 0 / 0 | 200 / 200 | ||||
結果 |
|
|
セット名 | テストケース |
---|---|
Sample | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt |
All | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_Yes_00.txt, 01_Yes_01.txt, 01_Yes_02.txt, 01_Yes_03.txt, 01_Yes_04.txt, 01_Yes_05.txt, 01_Yes_06.txt, 01_Yes_07.txt, 01_Yes_08.txt, 01_Yes_09.txt, 01_Yes_10.txt, 01_Yes_11.txt, 01_Yes_12.txt, 01_Yes_13.txt, 01_Yes_14.txt, 01_Yes_15.txt, 01_Yes_16.txt, 01_Yes_17.txt, 01_Yes_18.txt, 01_Yes_19.txt, 01_Yes_20.txt, 02_No_00.txt, 02_No_01.txt, 02_No_02.txt, 02_No_03.txt, 02_No_04.txt, 02_No_05.txt, 02_No_06.txt, 02_No_07.txt |
ケース名 | 結果 | 実行時間 | メモリ |
---|---|---|---|
00_sample_00.txt | AC | 1 ms | 7128 KiB |
00_sample_01.txt | AC | 1 ms | 7084 KiB |
00_sample_02.txt | AC | 1 ms | 7084 KiB |
01_Yes_00.txt | AC | 1 ms | 6900 KiB |
01_Yes_01.txt | AC | 1 ms | 7020 KiB |
01_Yes_02.txt | AC | 1 ms | 6804 KiB |
01_Yes_03.txt | AC | 1 ms | 7132 KiB |
01_Yes_04.txt | AC | 1 ms | 7068 KiB |
01_Yes_05.txt | AC | 1 ms | 7140 KiB |
01_Yes_06.txt | AC | 1 ms | 6936 KiB |
01_Yes_07.txt | AC | 1 ms | 7068 KiB |
01_Yes_08.txt | AC | 1 ms | 7024 KiB |
01_Yes_09.txt | AC | 2 ms | 7076 KiB |
01_Yes_10.txt | AC | 1 ms | 7084 KiB |
01_Yes_11.txt | AC | 1 ms | 7104 KiB |
01_Yes_12.txt | AC | 1 ms | 7108 KiB |
01_Yes_13.txt | AC | 1 ms | 6860 KiB |
01_Yes_14.txt | AC | 1 ms | 7140 KiB |
01_Yes_15.txt | AC | 1 ms | 7084 KiB |
01_Yes_16.txt | AC | 1 ms | 7136 KiB |
01_Yes_17.txt | AC | 1 ms | 7076 KiB |
01_Yes_18.txt | AC | 1 ms | 6868 KiB |
01_Yes_19.txt | AC | 1 ms | 7132 KiB |
01_Yes_20.txt | AC | 2 ms | 7088 KiB |
02_No_00.txt | AC | 1 ms | 7024 KiB |
02_No_01.txt | AC | 1 ms | 7080 KiB |
02_No_02.txt | AC | 1 ms | 7088 KiB |
02_No_03.txt | AC | 1 ms | 7088 KiB |
02_No_04.txt | AC | 1 ms | 7136 KiB |
02_No_05.txt | AC | 1 ms | 7016 KiB |
02_No_06.txt | AC | 1 ms | 6860 KiB |
02_No_07.txt | AC | 2 ms | 7032 KiB |