rt,下面是代码。
#include<bits/stdc++.h>
using namespace std;
const int N=4024;
int a[N][N],n,t,mp[2][N],tmp;
void dfs(int dep,int len){
int cur,cse[2];
cur=0;
cse[0]=a[dep][len];
cse[1]=a[n][len];
for(int i=dep+1;i<=n;i++){
cur^=1;
a[i][len+1]=cse[cur];
}
for(int i=dep+2;i<=n;i++){
a[i][len+2]=a[n+dep+1-i][len];
}
if(dep+2==n) return;
dfs(dep+2,len+2);
}
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
freopen("woof.in","r",stdin);
freopen("woof.out","w",stdout);
cin>>n>>t;
if(n==1){
cout<<1;
}
else if(n<=6){
if(n==2){
cout<<"1\n2 1";
}
if(n==3){
cout<<"1\n2 3\n3 1 2";
}
if(n==4){
cout<<"1\n2 4\n3 1 4\n4 3 2 1";
}
if(n==5){
cout<<"1\n2 5\n3 5 4\n4 1 3 2\n5 1 2 4 3";
}
if(n==6){
cout<<"1\n2 4\n3 6 2\n4 1 5 2\n5 3 1 6 4\n6 5 4 3 2 1";
}
}
else{
for(int i=1;i<=n;i++){
a[i][1]=i;
}
if(!(n&1)){
for(int i=1;i<=n;i++){
a[i][i]=1;
}
dfs(2,1);
}
else{
dfs(1,1);
}
for(int i=1;i<=n;i++){
for(int j=1;j<=i;j++){
cout<<a[i][j]<<" ";
}
cout<<"\n";
}
}
}