QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#856847 | #9917. The Story of Emperor Bie | Crysfly | Compile Error | / | / | Haskell | 737b | 2025-01-14 17:47:37 | 2025-01-14 17:47:39 |
Judging History
answer
import Data.List (maximum, elemIndices)
import Control.Monad (replicateM)
-- 读取一个整数
readInt :: IO Int
readInt = readLn
-- 读取一行整数列表
readInts :: IO [Int]
readInts = fmap (map read . words) getLine
-- 处理每个测试用例
work :: IO ()
work = do
n <- readInt -- 读取数组大小
a <- readInts -- 读取数组
let mx = maximum a -- 找到最大值
let indices = map (+1) (elemIndices mx a) -- 找到最大值的位置(从 1 开始)
putStrLn $ unwords $ map show indices
-- 主函数
main :: IO ()
main = do
t <- readInt -- 读取测试用例数
replicateM t work -- 处理每个测试用例
Details
<no location info>: warning: -XGeneralizedNewtypeDeriving is not allowed in Safe Haskell; ignoring -XGeneralizedNewtypeDeriving [1 of 2] Compiling Main ( answer.hs, answer.o ) answer.hs:25:5: error: • Couldn't match type ‘[()]’ with ‘()’ Expected: IO () Actual: IO [()] • In a stmt of a 'do' block: replicateM t work In the expression: do t <- readInt replicateM t work In an equation for ‘main’: main = do t <- readInt replicateM t work | 25 | replicateM t work -- 处理每个测试用例 | ^^^^^^^^^^^^^^^^^