Task: | Spiraali |
Sender: | masuman |
Submission time: | 2021-10-06 22:03:32 +0300 |
Language: | Python3 (CPython3) |
Status: | READY |
Result: | 35 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 15 |
#2 | ACCEPTED | 20 |
#3 | WRONG ANSWER | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | ACCEPTED | 0.03 s | 1 | details |
#2 | ACCEPTED | 0.04 s | 2 | details |
#3 | WRONG ANSWER | 0.04 s | 3 | details |
Code
def r(y,x,n,xx):return max(abs(int(xx[0]) - y),abs(int(xx[1]) - x))def ring(y,x,n):nw = (n/2, n/2)ne = (n/2, (n/2)+1)se = ((n/2)+1,(n/2)+1)sw = ((n/2)+1, n/2)if x <= n/2 and y <= n/2:return r(y,x,n,nw)if x > n/2 and y <= n/2:return r(y,x,n,ne)if x <= n/2 and y > n/2:return r(y,x,n,sw)if x > n/2 and y > n/2:return r(y,x,n,se)def ringCount(y,x,n):yNew = y - ((n/2)-1-ring(y,x,n))xNew = x - ((n/2)-1-ring(y,x,n))return (yNew, xNew)def runningNumber(y,x,p):p = (p+1)*2if (y,x) == (1,1):return 1if (y,x) == (p,1):return pif (y,x) == (p,p):return 2*p - 1if (y,x) == (1, p):return 3*p - 2if y == 1:return 4*p-2-xif y == p:return x+p-1if x == 1:return yif x == p:return 3*p-1-ydef s(n,p):return 4*p*(n-p)def f(y,x,n):k = ringCount(y,x,n)g = ring(y,x,n)p = runningNumber(k[0],k[1], g)d = (n/2)-g-1e = s(n, d)print(int(e+p))a, b = input().split()n = int(a)t = int(b)for i in range(t):a, b = input().split()y = int(a)x = int(b)f(y,x,n)
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: WRONG ANSWER
input |
---|
1000000000 1000 177757853 827347032 409613589 419171337 739269360 256524697 328695530 896842209 ... |
correct output |
---|
571375684522141210 967321186816598569 762879105851175000 370065046779516790 936897883750373771 ... |
user output |
---|
571375684522141184 967321186816598656 762879105851175040 370065046779516800 93689788375037 ... Truncated |