Submission #49206984


Source Code Expand

n = int(input())
ls = [[-1] * n for _ in range(n)]
d = [(0, 1), (1, 0), (0, -1), (-1, 0)]
di = 0
x, y = 0, 0

def valid(a, b):
    return 

for i in range(1, n * n):
    ls[x][y] = i
    x2, y2 = x + d[di][0], y + d[di][1]
    if (not (0 <= x2 < n and 0 <= y2 < n)) or ls[x2][y2] != -1:
        di = (di + 1) % len(d)
        x2, y2 = x + d[di][0], y + d[di][1]
    x, y = x2, y2
    # print(x, y)
for i in range(n):
    for j in range(n):
        if ls[i][j] != -1:
            print(ls[i][j], end="")
        else:
            print('T', end="")
        if j < n - 1:
            print(end=" ")
        else:
            print()

Submission Info

Submission Time
Task D - Loong and Takahashi
User shinever
Language Python (PyPy 3.10-v7.3.12)
Score 350
Code Size 656 Byte
Status AC
Exec Time 73 ms
Memory 81928 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 350 / 350
Status
AC × 1
AC × 22
Set Name Test Cases
Sample sample_01.txt
All random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, sample_01.txt
Case Name Status Exec Time Memory
random_01.txt AC 58 ms 76332 KiB
random_02.txt AC 57 ms 76236 KiB
random_03.txt AC 58 ms 76172 KiB
random_04.txt AC 57 ms 76544 KiB
random_05.txt AC 59 ms 76336 KiB
random_06.txt AC 59 ms 76332 KiB
random_07.txt AC 60 ms 76372 KiB
random_08.txt AC 60 ms 76280 KiB
random_09.txt AC 59 ms 76348 KiB
random_10.txt AC 60 ms 76236 KiB
random_11.txt AC 63 ms 80520 KiB
random_12.txt AC 64 ms 80492 KiB
random_13.txt AC 65 ms 81336 KiB
random_14.txt AC 67 ms 81072 KiB
random_15.txt AC 68 ms 81628 KiB
random_16.txt AC 72 ms 81928 KiB
random_17.txt AC 72 ms 81752 KiB
random_18.txt AC 73 ms 81804 KiB
random_19.txt AC 71 ms 81912 KiB
random_20.txt AC 73 ms 81612 KiB
random_21.txt AC 71 ms 81748 KiB
sample_01.txt AC 57 ms 76212 KiB