結果

問題 No.2212 One XOR Matrix
ユーザー Carpenters-CatCarpenters-Cat
提出日時 2023-02-11 04:48:54
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 112 ms / 2,000 ms
コード長 1,140 bytes
コンパイル時間 1,899 ms
コンパイル使用メモリ 175,752 KB
実行使用メモリ 20,680 KB
最終ジャッジ日時 2023-09-22 04:13:49
合計ジャッジ時間 4,084 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using Vi = vector<int>;
using VVi = std::vector<vector<int>> ;
int main () {
    int N;
    cin >> N;
    if (N == 1) {
        cout << -1 << endl;
        return 0;
    }
    VVi ans1 = {
    { 7, 14,  0,  8},
    { 4, 12,  2, 11},
    {15,  9,  6,  1},
    {13, 10,  5,  3}
    };
    VVi ans0 = {
    { 7, 14,  1,  8},
    { 4, 13,  2, 11},
    {15,  9,  6,  0},
    {12, 10,  5,  3}
    };
    for (int i = 3; i <= N; i ++) {
        VVi A0((1 << i), Vi(1 << i)), A1((1 << i), Vi(1 << i));
        for (int a = 0; a < 4; a ++) {
            int I = a / 2, J = a & 1;
            int s = a << (i * 2 - 2);
            int x = (1 << (i - 1));
            for (int p = 0; p < x; p ++) {
                for (int q = 0; q < x; q ++) {
                    A0[p + x * I][q + x * J] = s | ans0[p][q];
                    A1[p + x * I][q + x * J] = s | (I == J ? ans1 : ans0)[p][q];
                }
            }
        }
        ans0 = A0;
        ans1 = A1;
    }
    for (auto& a : ans1) {
        for (auto& b : a) {
            cout << b << " ";
        }
        cout << endl;
    }
    
}
0