結果

問題 No.2212 One XOR Matrix
ユーザー jianglyjiangly
提出日時 2023-02-10 21:38:21
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 68 ms / 2,000 ms
コード長 1,079 bytes
コンパイル時間 1,962 ms
コンパイル使用メモリ 202,476 KB
実行使用メモリ 7,420 KB
最終ジャッジ日時 2023-09-21 22:43:10
合計ジャッジ時間 4,126 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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