結果
問題 | No.2212 One XOR Matrix |
ユーザー |
|
提出日時 | 2023-02-11 17:36:29 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 69 ms / 2,000 ms |
コード長 | 954 bytes |
コンパイル時間 | 2,053 ms |
コンパイル使用メモリ | 202,544 KB |
最終ジャッジ日時 | 2025-02-10 14:25:31 |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 8 |
ソースコード
#include<bits/stdc++.h>using namespace std;using ll=long long;using pii=pair<int,int>;#define all(a) a.begin(),a.end()#define pb push_back#define sz(a) ((int)a.size())vector<vector<int>> a[10];signed main(){ios_base::sync_with_stdio(0),cin.tie(0);int n; cin >> n;if(n==1){cout << "-1\n";return 0;}a[2]={{7,14,0,8},{4,12,2,11},{15,9,6,1},{13,10,5,3}};for(int k=3; k<=n; ++k){a[k].assign(1<<k,vector<int>(1<<k));for(int i=0; i<(1<<k-1); ++i) for(int j=0; j<(1<<k-1); ++j) a[k][i][j]=a[k][i+(1<<k-1)][j+(1<<k-1)]=a[k-1][i][j],a[k][i+(1<<k-1)][j]=a[k][i][j+(1<<k-1)]=i*(1<<k-1)+j;for(int i=0; i<(1<<k); ++i) for(int j=0; j<(1<<k); ++j){if(i>>k-1) a[k][i][j]^=1<<(2*k-2);if(j>>k-1) a[k][i][j]^=1<<(2*k-1);}}for(int i=0; i<(1<<n); ++i){for(int j=0; j<(1<<n); ++j) cout << a[n][i][j] << ' ';cout << "\n";}}