結果

問題 No.2212 One XOR Matrix
ユーザー jiangly
提出日時 2023-02-10 21:38:21
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 75 ms / 2,000 ms
コード長 1,079 bytes
コンパイル時間 2,132 ms
コンパイル使用メモリ 198,284 KB
最終ジャッジ日時 2025-02-10 12:22:07
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using i64 = long long;

constexpr int pattern[4][4] = {
    {7, 14, 0, 8},
    {4, 12, 2, 11},
    {15, 9, 6, 1},
    {13, 10, 5, 3}
};

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    int n;
    std::cin >> n;
    
    if (n == 1) {
        std::cout << -1 << "\n";
        return 0;
    }
    
    std::vector a(1 << n, std::vector<int>(1 << n));
    int cur = 0;
    for (int i = 0; i < (1 << n); i += 4) {
        for (int j = 0; j < (1 << n); j += 4) {
            for (int x = 0; x < 4; x++) {
                for (int y = 0; y < 4; y++) {
                    if (i == j) {
                        a[i + x][j + y] = cur + pattern[x][y];
                    } else {
                        a[i + x][j + y] = cur + x * 4 + y;
                    }
                }
            }
            cur += 16;
        }
    }
    
    for (int i = 0; i < (1 << n); i++) {
        for (int j = 0; j < (1 << n); j++) {
            std::cout << a[i][j] << " \n"[j == (1 << n) - 1];
        }
    }
    
    return 0;
}
0