結果

問題 No.2212 One XOR Matrix
ユーザー i_am_noobi_am_noob
提出日時 2023-02-11 17:36:29
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 70 ms / 2,000 ms
コード長 954 bytes
コンパイル時間 2,111 ms
コンパイル使用メモリ 208,112 KB
実行使用メモリ 8,936 KB
最終ジャッジ日時 2023-09-22 14:00:03
合計ジャッジ時間 4,423 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 6 ms
4,384 KB
testcase_08 AC 19 ms
4,380 KB
testcase_09 AC 70 ms
8,936 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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";
    }
}
0