Task: | Spiraali |
Sender: | xnor |
Submission time: | 2021-10-06 23:02:44 +0300 |
Language: | Haskell |
Status: | READY |
Result: | 100 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 15 |
#2 | ACCEPTED | 20 |
#3 | ACCEPTED | 65 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | ACCEPTED | 0.01 s | 1 | details |
#2 | ACCEPTED | 0.01 s | 2 | details |
#3 | ACCEPTED | 0.02 s | 3 | details |
Compiler report
input/code.hs:23:23: warning: [-Wtype-defaults] * Defaulting the following constraints to type `Integer' (Integral b0) arising from a use of `^' at input/code.hs:23:23-25 (Num b0) arising from the literal `2' at input/code.hs:23:25 * In the first argument of `(-)', namely `m ^ 2' In the second argument of `(*)', namely `(m ^ 2 - t ^ 2)' In the first argument of `(+)', namely `4 * (m ^ 2 - t ^ 2)' | 23 | | otherwise = 4*(m^2 - t^2) + f t (x, y) | ^^^ input/code.hs:23:29: warning: [-Wtype-defaults] * Defaulting the following constraints to type `Integer' (Integral b0) arising from a use of `^' at input/code.hs:23:29-31 (Num b0) arising from the literal `2' at input/code.hs:23:31 * In the second argument of `(-)', namely `t ^ 2' In the second argument of `(*)', namely `(m ^ 2 - t ^ 2)' In the first argument of `(+)', namely `4 * (m ^ 2 - t ^ 2)' | 23 | | otherwise = 4*(m^2 -...
Code
import Control.Monadmain :: IO [()]main = do(t, n) <- readLinecoords <- replicateM (fromInteger t) readLinelet m = div n 2let coords' = map (\(x,y) -> (x - m, y - m)) coordsmapM (print . (f m)) coords'readLine :: IO (Integer, Integer)readLine = doline <- getLinelet [y, x] = map read $ words linepure (x, y)f :: Integer -> (Integer, Integer) -> Integerf m (x, y)| x == m = 5 * m - 1 - y| x == 1 - m = m + y| y == m = 3 * m - 1 + x| y == 1 - m = 7 * m - 2 - x| otherwise = 4*(m^2 - t^2) + f t (x, y)where t = max (distFromCenter x) (distFromCenter y)distFromCenter coord| coord <= 0 = 1 - coord| otherwise = coord
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: ACCEPTED
input |
---|
1000000000 1000 177757853 827347032 409613589 419171337 739269360 256524697 328695530 896842209 ... |
correct output |
---|
571375684522141210 967321186816598569 762879105851175000 370065046779516790 936897883750373771 ... |
user output |
---|
571375684522141210 967321186816598569 762879105851175000 370065046779516790 93689788375037 ... Truncated |