1 条题解
-
0
用动态矩阵生成循环赛日程,覆盖M=10的1024名选手,避免1001大小数组越界。
#include <bits/stdc++.h> using namespace std; int main(){ios::sync_with_stdio(false);cin.tie(nullptr); int m;cin>>m;int n=1<<m;vector<vector<int>>a(n,vector<int>(n));a[0][0]=1;for(int width=1;width<n;width*=2)for(int i=0;i<width;i++)for(int j=0;j<width;j++){a[i][j+width]=a[i][j]+width;a[i+width][j]=a[i][j]+width;a[i+width][j+width]=a[i][j];}for(auto&row:a){for(int j=0;j<n;j++)cout<<(j?" ":"")<<row[j];cout<<"\n";} return 0; }
- 1
信息
- ID
- 4000
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 5
- 标签
- 递交数
- 0
- 已通过
- 0
- 上传者