結果
問題 | No.675 ドットちゃんたち |
ユーザー |
|
提出日時 | 2018-09-24 23:12:35 |
言語 | Haskell (9.10.1) |
結果 |
AC
|
実行時間 | 1,202 ms / 2,000 ms |
コード長 | 1,256 bytes |
コンパイル時間 | 8,812 ms |
コンパイル使用メモリ | 169,856 KB |
実行使用メモリ | 207,744 KB |
最終ジャッジ日時 | 2024-09-24 17:28:56 |
合計ジャッジ時間 | 14,040 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 8 |
コンパイルメッセージ
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 Control.Applicative import Control.Monad import Data.List import Text.Printf type Vector a = [a] type Matrix a = [Vector a] (!+!) :: Num a => Vector a -> Vector a -> Vector a (!+!) a b = zipWith (+) a b vneg :: Num a => Vector a -> Vector a vneg a = map negate a (!-!) a b = a !+! (vneg b) (!.!) :: Num a => Vector a -> Vector a -> a (!.!) a b = sum $ zipWith (*) a b (!*) :: Num a => Vector a -> a -> Vector a (!*) a n = map (*n) a (*!) b a = a !* b (!/) a b = a !* (1 / b) vabs :: (Real a, Num a) => Vector a -> Double vabs a = sqrt $ sum $ map (realToFrac . (^2)) a (|*|) :: Num a => Matrix a -> Matrix a -> Matrix a (|*|) a b = map (\va -> map (\vb -> sum $ zipWith (*) va vb) (transpose b)) a (|+|) :: Num a => Matrix a -> Matrix a -> Matrix a (|+|) a b = zipWith (zipWith (+)) a b main = do [n,px,py] <- map read . words <$> getLine :: IO [Int] ms <- reverse <$> do replicateM n $ do com <- map read . words <$> getLine :: IO [Int] return $ case com of [1,dx] -> [[1,0,dx],[0,1,0],[0,0,1]] [2,dy] -> [[1,0,0],[0,1,dy],[0,0,1]] [3] -> [[0,1,0],[-1,0,0],[0,0,1]] mapM_ (\[[x],[y],_] -> printf "%d %d\n" x y) $ reverse . map (|*| [[px],[py],[1]]) $ (scanl1 (|*|) ms)