CSES - DatatÃ¤hti 2022 alku - Results
 Task: Spiraali Sender: Erikoisjaakari Submission time: 2021-10-06 18:25:54 Language: PyPy3 Status: READY Result: 35
Feedback
groupverdictscore
#1ACCEPTED15
#2ACCEPTED20
#30
Test results
testverdicttimegroup
#1ACCEPTED0.04 s1details
#2ACCEPTED0.14 s2details
#3--3details

### Code

```Q=' '
P=input
N=range
L='w'
K='p'
J='e'
I=int
G='s'
F=P().split(Q)
D=I(F[0])
O=I(F[1])
E=[]
for R in N(D):
M=[]
for S in N(D):M.append(0)
E.append(M)
H=1
A=0
B=0
C=G
while H<=D*D:
E[A][B]=H
if(A,B)==(D-1,0)or(A,B)==(D-1,D-1)or(A,B)==(0,D-1):
if C==G:C=J
elif C==J:C=K
elif C==K:C=L
elif C==L:C=G
if C==G:
A+=1
if E[A][B]!=0:C=J;B+=1;A-=1
elif C==J:
B+=1
if E[A][B]!=0:C=K;B-=1;A-=1
elif C==K:
A-=1
if E[A][B]!=0:C=L;A+=1;B-=1
elif C==L:
B-=1
if E[A][B]!=0:C=G;B+=1;A+=1
H+=1
for T in N(O):F=P().split(Q);A=I(F[0])-1;B=I(F[1])-1;print(E[A][B])
```

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

input
1000000000 1000
177757853 827347032
409613589 419171337
739269360 256524697
328695530 896842209
...

correct output
571375684522141210
967321186816598569
762879105851175000
370065046779516790
936897883750373771
...

user output
(empty)