| Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|
| 71744 | 胡海峰老师 | 方阵填数 | Python3 | Accepted | 40 MS | 3796 KB | 396 | 2024-04-27 15:46:31 |
n = int(input()) x,y =0 ,n-1 a =[[0]*n for x in range(n)] i = 1 dirs = [(1,0),(0,-1),(-1,0),(0,1)] a[x][y] = i while i<n**2: for d in dirs: x, y = x + d[0], y + d[1] while 0<=x<n and 0<=y<n and a[x][y]==0: i +=1 # Next Cell a[x][y] = i x,y = x + d[0], y + d[1] x,y = x-d[0],y-d[1] for row in a: print(*row)