Run ID | 作者 | 问题 | 语言 | 测评结果 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
39664 | 咕 | 爱睡觉的猫(cat)(2024岳阳市赛小学组) | C++ | 运行超时 | 1000 MS | 292 KB | 608 | 2024-05-05 09:08:07 |
#include <bits/stdc++.h> using namespace std; int n,s[105][105],x,y,t; int main(){ cin>>n; x=1; y=n; t=n*n; s[x][y]=t; t--; while(t){ while(x+1<=n&&s[x+1][y]==0){ x++; s[x][y]=t; t--; } while(y-1>0&&s[x][y-1]==0){ y--; s[x][y]=t; t--; } while(y+1>0&&s[x-1][y]==0){ y++; s[x][y]=t; t--; } while(x-1<=n&&s[x-1][y]==0){ x--; s[x][y]=t; t--; } } for(int i=1;i<=n;i++){ for(int j=1;j<=n;j++){ cout<<s[i][j]<<" "; } cout<<endl; } return 0; }