結果

問題 No.1738 What's in the box?
ユーザー sanao10000sanao10000
提出日時 2021-11-13 00:02:09
言語 Haskell
(9.8.2)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 3,513 bytes
コンパイル時間 4,508 ms
コンパイル使用メモリ 243,964 KB
実行使用メモリ 8,268 KB
最終ジャッジ日時 2023-08-17 05:32:08
合計ジャッジ時間 7,799 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
7,076 KB
testcase_01 AC 2 ms
7,076 KB
testcase_02 AC 2 ms
7,108 KB
testcase_03 AC 4 ms
7,912 KB
testcase_04 AC 3 ms
8,076 KB
testcase_05 AC 4 ms
8,016 KB
testcase_06 AC 3 ms
8,136 KB
testcase_07 AC 3 ms
8,048 KB
testcase_08 AC 3 ms
8,088 KB
testcase_09 AC 3 ms
8,268 KB
testcase_10 AC 3 ms
7,932 KB
testcase_11 AC 3 ms
7,964 KB
testcase_12 AC 3 ms
8,176 KB
testcase_13 AC 2 ms
7,220 KB
testcase_14 AC 2 ms
7,156 KB
testcase_15 AC 2 ms
7,220 KB
testcase_16 AC 2 ms
7,072 KB
testcase_17 AC 3 ms
7,188 KB
testcase_18 AC 3 ms
7,192 KB
testcase_19 AC 2 ms
7,164 KB
testcase_20 AC 3 ms
7,164 KB
testcase_21 AC 3 ms
7,456 KB
testcase_22 AC 3 ms
7,140 KB
testcase_23 AC 2 ms
7,180 KB
testcase_24 AC 3 ms
7,480 KB
testcase_25 AC 3 ms
7,352 KB
testcase_26 AC 3 ms
7,332 KB
testcase_27 AC 2 ms
7,188 KB
testcase_28 AC 3 ms
7,180 KB
testcase_29 AC 2 ms
7,224 KB
testcase_30 AC 2 ms
7,112 KB
testcase_31 AC 2 ms
7,208 KB
testcase_32 AC 3 ms
7,224 KB
testcase_33 AC 3 ms
7,796 KB
testcase_34 AC 3 ms
7,996 KB
testcase_35 AC 3 ms
7,728 KB
testcase_36 AC 3 ms
7,964 KB
testcase_37 AC 3 ms
7,824 KB
testcase_38 AC 3 ms
7,964 KB
testcase_39 AC 3 ms
7,932 KB
testcase_40 AC 4 ms
8,144 KB
testcase_41 AC 3 ms
8,120 KB
testcase_42 AC 4 ms
7,928 KB
testcase_43 AC 4 ms
8,168 KB
testcase_44 AC 3 ms
8,036 KB
testcase_45 AC 3 ms
8,020 KB
testcase_46 AC 3 ms
8,100 KB
testcase_47 AC 3 ms
7,984 KB
testcase_48 AC 3 ms
8,196 KB
testcase_49 AC 3 ms
7,972 KB
testcase_50 AC 4 ms
8,024 KB
testcase_51 AC 4 ms
8,160 KB
testcase_52 AC 4 ms
8,080 KB
testcase_53 AC 2 ms
7,104 KB
testcase_54 AC 3 ms
7,240 KB
testcase_55 AC 3 ms
7,144 KB
testcase_56 AC 3 ms
7,232 KB
testcase_57 AC 3 ms
7,112 KB
testcase_58 AC 3 ms
7,076 KB
testcase_59 AC 3 ms
7,052 KB
testcase_60 AC 2 ms
7,208 KB
testcase_61 AC 3 ms
7,104 KB
testcase_62 AC 2 ms
7,164 KB
testcase_63 AC 3 ms
7,168 KB
testcase_64 AC 2 ms
7,108 KB
testcase_65 AC 2 ms
7,140 KB
testcase_66 AC 2 ms
7,108 KB
testcase_67 AC 2 ms
7,124 KB
testcase_68 AC 3 ms
7,216 KB
testcase_69 AC 3 ms
7,236 KB
testcase_70 AC 2 ms
7,164 KB
testcase_71 AC 2 ms
7,228 KB
testcase_72 AC 2 ms
7,216 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(take n(repeat 0))) 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