Submission #49101809


Source Code Expand

#ABC335_20240106_D
D=[[0,1],[1,0],[0,-1],[-1,0]]
N=int(input())
M=[[0 for i in range(N)] for j in range(N)]
P=[0,0]
X=1
Y=0
M[(N+1)//2-1][(N+1)//2-1]="T"
while(X<N**2):
    M[P[0]][P[1]]=X
    X+=1
    P[0]+=D[Y][0]
    P[1]+=D[Y][1]
    #print(*M,sep="\n")
    if(Y==0):
        if(P[1]==N):
            P[1]-=1
            P[0]+=1
            Y=1
        elif(M[P[0]][P[1]]!=0):
            P[1]-=1
            P[0]+=1
            Y=1
    elif(Y==1):
        if(P[0]==N):
            P[0]-=1
            P[1]-=1
            Y=2
        elif(M[P[0]][P[1]]!=0):
            P[0]-=1
            P[1]-=1
            Y=2
    elif(Y==2):
        if(P[1]==-1):
            P[1]+=1
            P[0]-=1
            Y=3
        elif(M[P[0]][P[1]]!=0):
            P[1]+=1
            P[0]-=1
            Y=3
    elif(Y==3):
        if(P[0]==-1):
            P[0]+=1
            P[1]+=1
            Y=0
        elif(M[P[0]][P[1]]!=0):
            P[0]+=1
            P[1]+=1
            Y=0
for i in range(N):
    print(*M[i])

Submission Info

Submission Time
Task D - Loong and Takahashi
User Konini
Language Python (PyPy 3.10-v7.3.12)
Score 350
Code Size 1070 Byte
Status AC
Exec Time 71 ms
Memory 82168 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 76436 KiB
random_02.txt AC 59 ms 76460 KiB
random_03.txt AC 59 ms 76416 KiB
random_04.txt AC 61 ms 76616 KiB
random_05.txt AC 60 ms 76656 KiB
random_06.txt AC 62 ms 76840 KiB
random_07.txt AC 60 ms 76764 KiB
random_08.txt AC 61 ms 76648 KiB
random_09.txt AC 63 ms 76688 KiB
random_10.txt AC 60 ms 76632 KiB
random_11.txt AC 60 ms 76572 KiB
random_12.txt AC 62 ms 76928 KiB
random_13.txt AC 64 ms 80692 KiB
random_14.txt AC 67 ms 80948 KiB
random_15.txt AC 66 ms 82072 KiB
random_16.txt AC 68 ms 81696 KiB
random_17.txt AC 69 ms 82136 KiB
random_18.txt AC 68 ms 82168 KiB
random_19.txt AC 69 ms 82124 KiB
random_20.txt AC 71 ms 82128 KiB
random_21.txt AC 71 ms 81692 KiB
sample_01.txt AC 61 ms 76500 KiB