結果

問題 No.2212 One XOR Matrix
ユーザー umimelumimel
提出日時 2023-02-10 22:48:57
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 87 ms / 2,000 ms
コード長 1,652 bytes
コンパイル時間 2,064 ms
コンパイル使用メモリ 178,056 KB
実行使用メモリ 14,080 KB
最終ジャッジ日時 2023-09-21 23:57:52
合計ジャッジ時間 4,406 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
#define drep(i, cc, n) for (ll i = (cc); i <= (n); ++i)
#define rep(i, n) drep(i, 0, n - 1)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define fi first
#define se second

const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const ll INF = 1LL << 60;
const ll MAX_N = 2e5;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    ll n;
    cin >> n;

    if(n==1){
        cout << -1 << endl;
        return 0;
    }

    vector<vector<vector<ll>>> a(n+1);
    //n=2の場合の初期化
    a[2].resize((1<<2), vector<ll>(1<<2));
    a[2]={
        {7, 14, 0, 8},
        {4, 12, 2, 11},
        {15, 9, 6, 1},
        {13, 10, 5, 3}
    };

    for(ll x=3; x<=n; x++){
        a[x].resize((1<<x), vector<ll>((1<<x)));
        //左上
        for(ll i=0; i<(1<<(x-1)); i++) for(ll j=0; j<(1<<(x-1)); j++) a[x][i][j] = a[x-1][i][j];
        //右上
        for(ll i=0; i<(1<<(x-1)); i++) for(ll j=(1<<(x-1)); j<(1<<x); j++){
            a[x][i][j] = (1<<(2*x-2))+i*(1<<(x-1))+(j-(1<<(x-1)));
        }
        //左下
        for(ll i=(1<<(x-1)); i<(1<<x); i++) for(ll j=0; j<(1<<(x-1)); j++){
            a[x][i][j] = (1<<(2*x-1))+(i-(1<<(x-1)))*(1<<(x-1))+j;
        }
        //右下
        for(ll i=(1<<(x-1)); i<(1<<x); i++) for(ll j=(1<<(x-1)); j<(1<<x); j++){
            a[x][i][j] = (1<<(2*x-1))+(1<<(2*x-2))+a[x-1][i-(1<<(x-1))][j-(1<<(x-1))];
        }
    }

    for(ll i=0; i<(1<<n); i++){
        for(ll j=0; j<(1<<n); j++){
            cout << a[n][i][j] << " ";
        }
        cout << endl;
    }
}
0