| Task: | Spiraali |
| Sender: | Og3 |
| Submission time: | 2021-10-07 10:53:16 +0300 |
| Language: | Python3 (CPython3) |
| 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.02 s | 1 | details |
| #2 | ACCEPTED | 0.12 s | 2 | details |
| #3 | TIME LIMIT EXCEEDED | -- | 3 | details |
Code
n, t = [int(x) for x in input().split()]
n2=n**2
n12=n/2
for h in range (t):
y, x = [int(x) for x in input().split()]
a=0
if y<(n12+1):
y0=y-n12-1
else:
y0=y-n12
if x<(n12+1):
x0=x-n12-1
else:
x0=x-n12
#print(y0)
#print(x0)
if abs(x0)>abs(y0):
k=abs(x0)
if x0>0:
while y0!=x0:
a+=1
if y0==-1:
y0+=2
else:
y0+=1
print(str(int(n2+1-4*k**2+a+4*k-2)))
else:
while y0!=x0:
a+=1
if y0==1:
y0-=2
else:
y0-=1
print(str(int(n2+1-4*k**2+a)))
else:
k=abs(y0)
if y0==x0:
if y0>0:
if x0>0:
print(str(int(n2+1-4*k**2+4*k-2)))
else:
print(str(int(n2+1-4*k**2+2*k-1)))
else:
if x0>0:
print(str(int(n2+1-4*k**2+6*k-3)))
else:
print(str(int(n2+1-4*k**2)))
elif y0<0:
while x0!=abs(y0):
a+=1
if x0==-1:
x0+=2
else:
x0+=1
print(str(int(n2+1-4*k**2+a+6*k-3)))
else:
while abs(x0)!=y0:
a+=1
if x0==1:
x0-=2
else:
x0-=1
print(str(int(n2+1-4*k**2+a+2*k-1)))
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) |
