Submission #421372
Source Code Expand
{-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE ScopedTypeVariables #-} import Control.Applicative import qualified Data.ByteString.Char8 as S import Data.Complex import Data.Monoid import Data.Vector.Generic ((!)) import qualified Data.Vector.Generic as G import qualified Data.Vector.Unboxed as VU fft :: VU.Vector (Complex Double) -> VU.Vector (Complex Double) fft v | G.length v == 2 = G.fromList [v!0+v!1, v!0-v!1] | otherwise = ret where xs = fft $ G.ifilter (const . even) v ys = fft $ G.ifilter (const . odd ) v len = G.length ys ret = G.zipWith3 f es xs ys <> G.zipWith3 g es xs ys f e x y = x + y * e g e x y = x - y * e es = VU.generate len $ \k -> exp (-(2*pi*fromIntegral k*(0:+1))/fromIntegral(len*2)) ifft :: VU.Vector (Complex Double) -> VU.Vector (Complex Double) ifft xs = G.map (/ fromIntegral (G.length xs)) (fft xs) main :: IO () main = do n <- readLn (ns :: VU.Vector (Int, Int)) <- VU.replicateM n $ do [a, b] <- map (maybe 0 fst . S.readInt) . S.words <$> S.getLine return (a, b) let len = head [ 2^i | i <- [0 :: Int ..], 2^i>=n*2] extend v = G.concat [G.singleton 0, G.map fromIntegral v, G.replicate (len - n - 1) 0] (as, bs) = G.unzip ns ans = ifft $ G.zipWith (*) (fft $ extend as) (fft $ extend bs) G.forM_ (G.reverse ans) $ \c -> print (round $ realPart c :: Int)
Submission Info
Submission Time | |
---|---|
Task | C - 高速フーリエ変換 |
User | tanakh |
Language | Haskell (Haskell Platform 2014.2.0.0) |
Score | 0 |
Code Size | 1473 Byte |
Status | WA |
Exec Time | 3614 ms |
Memory | 55720 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 100 | ||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 00_sample_01 |
All | 00_sample_01, 01_00_01, 01_01_19, 01_02_31, 01_03_22, 01_04_31, 01_05_40, 01_06_15, 01_07_39, 01_08_28, 01_09_30, 01_10_23, 01_11_33, 01_12_11, 01_13_28, 01_14_41, 01_15_26, 01_16_49, 01_17_34, 01_18_02, 01_19_33, 01_20_29, 02_00_51254, 02_01_82431, 02_02_17056, 02_03_34866, 02_04_6779, 02_05_65534, 02_06_65535, 02_07_65536, 02_08_65537, 02_09_65538, 02_10_100000 |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_sample_01 | AC | 32 ms | 1232 KB |
01_00_01 | AC | 30 ms | 1044 KB |
01_01_19 | WA | 34 ms | 1500 KB |
01_02_31 | WA | 32 ms | 1492 KB |
01_03_22 | WA | 33 ms | 1548 KB |
01_04_31 | WA | 33 ms | 1488 KB |
01_05_40 | WA | 34 ms | 1748 KB |
01_06_15 | WA | 32 ms | 1360 KB |
01_07_39 | WA | 34 ms | 1620 KB |
01_08_28 | WA | 33 ms | 1552 KB |
01_09_30 | WA | 33 ms | 1488 KB |
01_10_23 | WA | 33 ms | 1492 KB |
01_11_33 | WA | 35 ms | 1624 KB |
01_12_11 | WA | 32 ms | 1384 KB |
01_13_28 | WA | 36 ms | 1608 KB |
01_14_41 | WA | 34 ms | 1720 KB |
01_15_26 | WA | 33 ms | 1568 KB |
01_16_49 | WA | 34 ms | 1744 KB |
01_17_34 | WA | 34 ms | 1744 KB |
01_18_02 | AC | 33 ms | 1232 KB |
01_19_33 | WA | 34 ms | 1744 KB |
01_20_29 | WA | 33 ms | 1504 KB |
02_00_51254 | WA | 1715 ms | 30804 KB |
02_01_82431 | WA | 3576 ms | 51620 KB |
02_02_17056 | WA | 831 ms | 14420 KB |
02_03_34866 | WA | 1709 ms | 30804 KB |
02_04_6779 | WA | 214 ms | 4820 KB |
02_05_65534 | WA | 1745 ms | 30288 KB |
02_06_65535 | WA | 1758 ms | 30800 KB |
02_07_65536 | AC | 1750 ms | 29524 KB |
02_08_65537 | WA | 3504 ms | 48844 KB |
02_09_65538 | WA | 3519 ms | 49600 KB |
02_10_100000 | WA | 3614 ms | 55720 KB |