結果

問題 No.2212 One XOR Matrix
ユーザー みここみここ
提出日時 2023-02-10 22:12:39
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 115 ms / 2,000 ms
コード長 1,452 bytes
コンパイル時間 710 ms
コンパイル使用メモリ 70,124 KB
実行使用メモリ 7,748 KB
最終ジャッジ日時 2023-09-21 23:27:34
合計ジャッジ時間 3,081 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
using namespace std;

int ans[1100][1100];

void draw(int x, int y, int n)
{
    for(int c = 0; c < 4; c++)
    {
        ans[x][y] ^= 1;
        int u = (1 << n) - 1 - y;
        int v = x;
        swap(u, x);
        swap(v, y);
    }
}

int main()
{
    int n;
    cin >> n;
    if(n == 1)
    {
        cout << -1 << endl;
        return 0;
    }
    for(int c = 1; c < n; c++)
    {
        for(int i = 0; i < (1 << n); i++)
        {
            for(int j = 0; j < (1 << n); j++)
            {
                if((i >> c) & 1)
                {
                    ans[i][j] ^= (1 << c);
                }
                if((j >> c) & 1)
                {
                    ans[i][j] ^= (1 << (c + n));
                }
            }
        }
    }
    for(int i = 0; i < (1 << n); i++)
    {
        for(int j = 0; j < (1 << n); j++)
        {
            if((i + j) % 2)
            {
                ans[i][j] ^= (1 << n);
            }
        }
    }
    for(int k = 0; k < (1 << (n - 2)) - 1; k++)
    {
        for(int l = 0; l < (k + 1) * 2; l++)
        {
            draw(l, k * 2 + 1, n);
            draw(k * 2 + 2, l, n);
        }
    }
    for(int l = 0; l < (1 << (n - 1)); l++)
    {
        draw(l, (1 << (n - 1)) - 1, n);
    }
    for(int i = 0; i < (1 << n); i++)
    {
        for(int j = 0; j < (1 << n); j++)
        {
            cout << ans[i][j] << " ";
        }
        cout << "\n";
    }
}
0