結果

問題 No.1738 What's in the box?
ユーザー sanao10000sanao10000
提出日時 2021-11-12 23:59:48
言語 Haskell
(9.8.2)
結果
WA  
実行時間 -
コード長 3,510 bytes
コンパイル時間 21,573 ms
コンパイル使用メモリ 243,304 KB
実行使用メモリ 8,340 KB
最終ジャッジ日時 2023-08-17 05:22:52
合計ジャッジ時間 21,941 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
7,220 KB
testcase_01 AC 2 ms
7,196 KB
testcase_02 AC 2 ms
7,252 KB
testcase_03 AC 3 ms
8,076 KB
testcase_04 AC 3 ms
8,172 KB
testcase_05 AC 3 ms
8,008 KB
testcase_06 AC 3 ms
8,076 KB
testcase_07 AC 3 ms
8,172 KB
testcase_08 AC 3 ms
8,088 KB
testcase_09 AC 3 ms
8,180 KB
testcase_10 AC 3 ms
8,000 KB
testcase_11 AC 3 ms
7,948 KB
testcase_12 AC 4 ms
8,116 KB
testcase_13 AC 3 ms
7,212 KB
testcase_14 AC 2 ms
7,252 KB
testcase_15 AC 2 ms
7,156 KB
testcase_16 AC 3 ms
7,240 KB
testcase_17 AC 3 ms
7,172 KB
testcase_18 AC 2 ms
7,224 KB
testcase_19 AC 3 ms
7,292 KB
testcase_20 AC 2 ms
7,360 KB
testcase_21 AC 2 ms
7,376 KB
testcase_22 AC 3 ms
7,160 KB
testcase_23 AC 2 ms
7,232 KB
testcase_24 AC 3 ms
7,548 KB
testcase_25 AC 3 ms
7,444 KB
testcase_26 AC 3 ms
7,284 KB
testcase_27 AC 3 ms
7,216 KB
testcase_28 AC 2 ms
7,264 KB
testcase_29 AC 2 ms
7,188 KB
testcase_30 AC 3 ms
7,176 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 3 ms
7,888 KB
testcase_34 AC 3 ms
7,980 KB
testcase_35 AC 3 ms
7,892 KB
testcase_36 AC 4 ms
8,044 KB
testcase_37 AC 3 ms
7,880 KB
testcase_38 AC 4 ms
8,128 KB
testcase_39 AC 4 ms
8,044 KB
testcase_40 AC 3 ms
8,112 KB
testcase_41 AC 3 ms
8,184 KB
testcase_42 AC 4 ms
7,912 KB
testcase_43 AC 3 ms
8,128 KB
testcase_44 AC 4 ms
8,160 KB
testcase_45 AC 3 ms
7,984 KB
testcase_46 AC 3 ms
8,204 KB
testcase_47 AC 3 ms
8,024 KB
testcase_48 AC 4 ms
8,340 KB
testcase_49 AC 4 ms
8,028 KB
testcase_50 AC 3 ms
8,076 KB
testcase_51 AC 4 ms
8,140 KB
testcase_52 AC 3 ms
8,164 KB
testcase_53 AC 3 ms
7,228 KB
testcase_54 AC 3 ms
7,252 KB
testcase_55 AC 3 ms
7,228 KB
testcase_56 AC 2 ms
7,288 KB
testcase_57 AC 2 ms
7,132 KB
testcase_58 AC 2 ms
7,184 KB
testcase_59 AC 2 ms
7,212 KB
testcase_60 AC 2 ms
7,244 KB
testcase_61 AC 3 ms
7,184 KB
testcase_62 AC 3 ms
7,244 KB
testcase_63 AC 3 ms
7,168 KB
testcase_64 AC 3 ms
7,168 KB
testcase_65 AC 2 ms
7,204 KB
testcase_66 AC 2 ms
7,128 KB
testcase_67 AC 2 ms
7,148 KB
testcase_68 AC 3 ms
7,160 KB
testcase_69 AC 3 ms
7,132 KB
testcase_70 AC 3 ms
7,160 KB
testcase_71 AC 2 ms
7,196 KB
testcase_72 AC 2 ms
7,196 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 #

{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE FlexibleContexts    #-}
{-# LANGUAGE FlexibleInstances   #-}
{-# LANGUAGE OverloadedStrings #-}

import Control.Applicative
import Control.Monad.State
import qualified Numeric                       as Nu
import qualified Control.Monad                 as CM
import qualified Data.List                     as L
import qualified Control.Monad.ST              as ST
import qualified Data.ByteString.Char8         as BS
import qualified Data.Array                    as A
import qualified Data.Array.IO                 as AI
import qualified Data.Char                     as Ch
import qualified Data.Text                     as T
import qualified Data.IORef                    as IO
import qualified Data.Text.IO                  as T
import qualified Data.Array.ST                 as AST
import qualified Data.ByteString.Builder       as BB
import qualified Data.Set                      as Set
import qualified Data.Map.Strict               as Map
import qualified Data.Sequence                 as Seq
import qualified Data.Maybe                    as May
import Data.Graph
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable                  as VM
import Prelude hiding (print)


main = do
    [n,m] <- cin @[Int]
    hs<-V.fromList<$>cin @[Int]
    let a= V.sum hs
    aa<-VM.replicate n (0::Int)
    b<-V.thaw hs
    CM.forM_ (V.fromList[0..n-1]) $ \i->do
        VM.modify b (\x->x*m) i
        v<-(VM.read b i)
        VM.write aa i(div(v)a)
    c<-V.freeze aa
    putStr $ if a==0 then unwords(map show(replicate 0 n)) else unwords(map show(V.toList c))
    





type Moji= BS.ByteString



buildUndirected :: [(Int,Int)] -> [(Int,Int)]
buildUndirected x= Set.toList$Set.fromList $ concatMap (\ (a, b) -> [(a, b), (b, a)]) x



print :: Show a => a -> IO ()
print x=BS.putStrLn $ BS.pack $ show x

class Sanao a where
  sanao :: Moji -> a
  {-# MINIMAL sanao #-}

instance Sanao Moji  where
  sanao= id

instance Sanao Int where
    sanao x= case BS.readInt x of
                Nothing -> error "ここはInt"
                Just (a,_) -> a

instance Sanao Double where
    sanao x= case BS.readInt x of
                Nothing -> error "ここはDouble"
                Just (a,_) -> realToFrac a

instance Sanao [Moji] where
    sanao=BS.words

instance (Sanao a)=>Sanao [a] where
    sanao= map sanao.BS.words

instance Sanao(Int,Int) where
    sanao= (\[a, b]->(a, b)) . map sanao . BS.words

instance Sanao(Int, Int, Int) where
    sanao= (\[a, b, c]->(a, b, c)) . map sanao . BS.words

instance Sanao(Int, Int, Int, Int) where
    sanao= (\[a, b, c, d]->(a, b, c, d)) . map sanao . BS.words

instance Sanao(Double,Double) where
    sanao= (\[a, b]->(a, b)) . map sanao . BS.words

instance Sanao(Double,Double, Double) where
    sanao= (\[a, b, c]->(a, b, c)) . map sanao . BS.words

instance Sanao(Double,Double, Double, Double) where
    sanao= (\[a, b, c, d]->(a, b, c, d)) . map sanao . BS.words

instance Sanao(Moji,Int) where
    sanao= (\[a, b]->(a,sanao b)) . BS.words

instance Sanao(Moji,Int, Int) where
    sanao= (\[a, b, c]->(a,sanao b, sanao c)) . BS.words

instance Sanao(Int,Moji) where
    sanao= (\[a, b]->(sanao a,b)) . BS.words

instance Sanao(Moji,Double) where
    sanao= (\[a, b]->(a,sanao b)) . BS.words

cin::Sanao a=>IO a
cin=sanao<$>BS.getLine

instance Sanao(Double,Moji) where
    sanao= (\[a, b]->(sanao a,b)) . BS.words

0