CSES - DatatÃ¤hti 2022 alku - Results
 Task: Spiraali Sender: severi Submission time: 2021-10-17 13:23:06 Language: PyPy3 Status: READY Result: 100
Feedback
groupverdictscore
#1ACCEPTED15
#2ACCEPTED20
#3ACCEPTED65
Test results
testverdicttimegroup
#1ACCEPTED0.04 s1details
#2ACCEPTED0.08 s2details
#3ACCEPTED0.08 s3details

### Code

```njat = input().split(" ")
n = int(njat[0])
t = int(njat[1])

i = 0
kordinaatit = []

while i < t:
kordinaatit.append(input())
i += 1

layers = round(n / 2 + 0.1)
i = 0
ruudukko = n * n
while i < t:
xy = kordinaatit[i].split(" ")
y = int(xy[0])
x = int(xy[1])
k = n + 1 - x
s = n + 1 - y
layer = x
if y < x:
layer = y
if s < layer:
layer = s
if k < layer:
layer = k
inner = n - (2 * (layer - 1))
ekaruutu = ruudukko - inner * inner + 1
if x == layer:
vastaus = y - layer + ekaruutu
elif s == layer:
vastaus = x - layer + ekaruutu + inner - 1
elif y == layer:
vastaus = ekaruutu + inner + inner + inner - 3 + k - layer
else:
vastaus = ekaruutu + inner + inner - 2 + s - layer
print(vastaus)
i += 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
...

#### 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
...

#### 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
936897883750373771
...