| Task: | Spiraali |
| Sender: | ZakkeX |
| Submission time: | 2021-10-04 10:54:03 +0300 |
| Language: | Haskell |
| Status: | READY |
| Result: | 35 |
| group | verdict | score |
|---|---|---|
| #1 | ACCEPTED | 15 |
| #2 | ACCEPTED | 20 |
| #3 | TIME LIMIT EXCEEDED | 0 |
| test | verdict | time | group | |
|---|---|---|---|---|
| #1 | ACCEPTED | 0.01 s | 1 | details |
| #2 | ACCEPTED | 0.03 s | 2 | details |
| #3 | TIME LIMIT EXCEEDED | -- | 3 | details |
Compiler report
input/code.hs:1:1: warning: [-Wmissing-signatures]
Top-level binding with no type signature: main :: IO ()
|
1 | main = do
| ^^^^
input/code.hs:2:8: warning: [-Wunused-matches]
Defined but not used: `t'
|
2 | [n,t] <- map read . words <$> getLine
| ^
input/code.hs:2:18: warning: [-Wtype-defaults]
* Defaulting the following constraints to type `Integer'
(Read a0) arising from a use of `read' at input/code.hs:2:18-21
(Show a0) arising from a use of `print' at input/code.hs:3:12-16
(Ord a0) arising from a use of `luku' at input/code.hs:3:20-25
(Num a0) arising from a use of `luku' at input/code.hs:3:20-25
* In the first argument of `map', namely `read'
In the first argument of `(.)', namely `map read'
In the first argument of `(<$>)', namely `map read . words'
|
2 | [n,t] <- map read . words <$> getLine
| ^^^^
input/code.hs:5:1: warning: [-Wmissing-signatures]
Top-level binding...Code
main = do
[n,t] <- map read . words <$> getLine
mapM_ (print . luku n . (\[y,x] -> (x, y)) . map read . words) . lines =<< getContents
kuorittava n p = syvyys n p > 1
syvyys n (x, y) = min (syvyys' n x) (syvyys' n y)
where syvyys' n x = min x $ abs (n-x) + 1
kuori (x, y) = (x - 1, y - 1)
luku n p@(x, y)
| kuorittava n p = 4 * (n - 1) + luku (n-2) (kuori p)
| otherwise = reunapituus n p
reunapituus n (x, y)
| x == 1 = y
| y == n = n - 1 + x
| x == n = 2 * (n - 1) + abs (n-y) + 1
| y == 1 = 3 * (n - 1) + abs (n-x) + 1
| otherwise = error "Spiraalia ei ole kuorittu tarpeeksi!"
Test details
Test 1
Group: 1
Verdict: ACCEPTED
| input |
|---|
| 10 100 1 1 1 2 1 3 1 4 ... |
| correct output |
|---|
| 1 36 35 34 33 ... |
| user output |
|---|
| 1 36 35 34 33 ... Truncated |
Test 2
Group: 2
Verdict: ACCEPTED
| input |
|---|
| 1000 1000 371 263 915 322 946 880 53 738 ... |
| correct output |
|---|
| 773533 312166 206053 200080 593922 ... |
| user output |
|---|
| 773533 312166 206053 200080 593922 ... Truncated |
Test 3
Group: 3
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 1000000000 1000 177757853 827347032 409613589 419171337 739269360 256524697 328695530 896842209 ... |
| correct output |
|---|
| 571375684522141210 967321186816598569 762879105851175000 370065046779516790 936897883750373771 ... |
| user output |
|---|
| (empty) |
