Task: | Spiraali |
Sender: | elias26 |
Submission time: | 2021-10-09 12:34:13 +0300 |
Language: | Python3 (PyPy3) |
Status: | READY |
Result: | 15 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 15 |
#2 | TIME LIMIT EXCEEDED | 0 |
#3 | TIME LIMIT EXCEEDED | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | ACCEPTED | 0.04 s | 1 | details |
#2 | TIME LIMIT EXCEEDED | -- | 2 | details |
#3 | TIME LIMIT EXCEEDED | -- | 3 | details |
Code
n, t = map(int, input().split()) tests = [] for i in range(t): x, y = map(int, input().split()) tests.append([x,y]) turningPoints = [] def generateTurningPoint(i, n): return round((1.0/8.0)*( -2.0 * i**2.0 + (n *8.0)*i + (-1.0**(i+1.0))+1.0)) i = 0 while True: next = generateTurningPoint(i,n) turningPoints.append(next) i += 1 if next == n**2: break; coordinate = [1,1] direction = [1,0] possibleDirections = [[0,1],[-1,0],[0,-1],[1,0]] coordinateToValue = {} for i in range(1, n * n + 1): if i in turningPoints: direction = possibleDirections[0] possibleDirections.remove(direction) possibleDirections.append(direction) coordinateToValue[repr([coordinate[0], coordinate[1]])] = i coordinate[0] += direction[0] coordinate[1] += direction[1] for test in tests: print(coordinateToValue[str(test)])
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: TIME LIMIT EXCEEDED
input |
---|
1000 1000 371 263 915 322 946 880 53 738 ... |
correct output |
---|
773533 312166 206053 200080 593922 ... |
user output |
---|
(empty) |
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) |