CSES - Putka Open 2015 – 5/6 - Results
Submission details
Task:Käännöt
Sender:
Submission time:2015-11-08 05:19:55 +0200
Language:Haskell
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
Test results
testverdicttimegroup
#10.07 s1details
#20.06 s1details
#30.06 s1details
#40.08 s1details
#50.06 s1details
#60.07 s2details
#70.08 s2details
#80.07 s2details
#90.08 s2details
#100.07 s2details
#110.31 s3details
#120.32 s3details
#130.32 s3details
#140.32 s3details
#150.32 s3details

Compiler report

input/code.hs:6:1: Warning:
    Top-level binding with no type signature: maxN :: Int

input/code.hs:6:10: Warning:
    Defaulting the following constraint(s) to type `Integer'
      (Integral b0) arising from a use of `^' at input/code.hs:6:10
      (Num b0) arising from the literal `5' at input/code.hs:6:11
    In the expression: 10 ^ 5
    In an equation for `maxN': maxN = 10 ^ 5

input/code.hs:8:1: Warning:
    Top-level binding with no type signature: main :: IO ()

input/code.hs:19:22: Warning:
    This binding for `sum' shadows the existing binding
      imported from `Data.List' at input/code.hs:4:1-16

input/code.hs:31:7: Warning:
    Defaulting the following constraint(s) to type `Integer'
      (Integral b0) arising from a use of `^' at input/code.hs:31:7
      (Num b0) arising from the literal `9' at input/code.hs:31:8
    In the first argument of `(+)', namely `10 ^ 9'
    In the expression: 10 ^ 9 + 7
    In an equation for `m': m = 10 ^ 9 + 7

input/code.hs:44:17: Warni...

Code

import Data.Array.Unboxed
import Data.Char
import Data.Int
import Data.List

maxN = 10^5

main = do
  xs <- fmap (reverse . map digitToInt . filter isDigit) getContents
  let n = genericLength xs :: Integer
  let xs_a :: UArray Int Int64
      xs_a = listArray (0,fromIntegral n-1) $ map fromIntegral xs
  print n
  print xs_a
  print (map pow10 [0..10])
  print (map pow10_range [0..10])
  let t :: UArray Int Int64
      t = listArray (0, fromIntegral (n+1)`div`2) . map (fromIntegral . fst) . genericTake n
        $ iterate (\(sum,i) -> ((sum+pow10_range(n-i-1)-pow10_range(i-1)+m)`mod`m,i+1)) (pow10_range (n-1), 1)
  let t2::Integer->Integer; t2 i = fromIntegral $ t ! fromIntegral (min i (n-i-1))
  print (map t2 [0..n-1])
  let pairs::Integer->Integer; pairs 0 = 0; pairs k = ((k-1)*(k-2)`div`2 + k-1)`mod`m
  let f1 :: Integer -> Integer; f1 k = fromIntegral (xs_a!fromIntegral k) * pow10 k * fromIntegral (pairs(k+1) + pairs(n-k))
  let f2 :: Integer -> Integer; f2 k = fromIntegral (xs_a!fromIntegral k) * t2 k
  let s = foldl' (\acc k -> (acc+f1 k+f2 k)`mod`m) 0 [0..n-1]
  print (map f1 [0..n-1])
  print (map f2 [0..n-1])
  print s

m :: Integral a => a
m = 10^9+7

pow10 :: Integer -> Integer
pow10 k = fromIntegral $ pow10_a ! fromIntegral k

pow10_range :: Integer -> Integer
pow10_range k = fromIntegral $ pow10_range_a ! fromIntegral k

pow10_a :: UArray Int Int64
pow10_a = listArray (0, maxN) . take maxN $ iterate (\n -> n*10`mod`m) 1

pow10_range_a :: UArray Int Int64
pow10_range_a = listArray (0, maxN) . map (fromIntegral . fst) . take maxN
   $ iterate (\(sum,i) -> ((sum+pow10 i)`mod`m,i+1)) (1,1)

Test details

Test 1

Group: 1

Verdict:

input
825864589849478186996872119675...

correct output
457966376

user output
100
array (0,99) [(0,8),(1,6),(2,8...

Test 2

Group: 1

Verdict:

input
191658935877461356157657491987...

correct output
176954270

user output
100
array (0,99) [(0,9),(1,9),(2,4...

Test 3

Group: 1

Verdict:

input
348988594526165698179722696175...

correct output
338693404

user output
100
array (0,99) [(0,2),(1,7),(2,9...

Test 4

Group: 1

Verdict:

input
959161872742625799336943933597...

correct output
585928712

user output
100
array (0,99) [(0,2),(1,6),(2,3...

Test 5

Group: 1

Verdict:

input
925429363246698689162197257943...

correct output
517617697

user output
100
array (0,99) [(0,1),(1,9),(2,4...

Test 6

Group: 2

Verdict:

input
972591294933975999938266397628...

correct output
667001154

user output
5000
array (0,4999) [(0,8),(1,8),(2...

Test 7

Group: 2

Verdict:

input
275688881195265674233697529772...

correct output
213272855

user output
5000
array (0,4999) [(0,8),(1,3),(2...

Test 8

Group: 2

Verdict:

input
654678934762543351831648468742...

correct output
465477034

user output
5000
array (0,4999) [(0,8),(1,5),(2...

Test 9

Group: 2

Verdict:

input
852895263384279396767531876338...

correct output
225052500

user output
5000
array (0,4999) [(0,1),(1,8),(2...

Test 10

Group: 2

Verdict:

input
257723665884149498894428498943...

correct output
169577498

user output
5000
array (0,4999) [(0,1),(1,6),(2...

Test 11

Group: 3

Verdict:

input
965391619923528543348143963721...

correct output
458795777

user output
100000
array (0,99999) [(0,3),(1,8),(...

Test 12

Group: 3

Verdict:

input
934996116481518541954869782274...

correct output
38884659

user output
100000
array (0,99999) [(0,7),(1,3),(...

Test 13

Group: 3

Verdict:

input
356521595763548549682719476371...

correct output
335143519

user output
100000
array (0,99999) [(0,4),(1,4),(...

Test 14

Group: 3

Verdict:

input
691571977153731228387836644955...

correct output
504860195

user output
100000
array (0,99999) [(0,9),(1,2),(...

Test 15

Group: 3

Verdict:

input
882254176987218851832315176774...

correct output
32749477

user output
100000
array (0,99999) [(0,5),(1,6),(...