結果

問題 No.2212 One XOR Matrix
ユーザー 鴨志田卓鴨志田卓
提出日時 2023-02-16 00:14:43
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 102 ms / 2,000 ms
コード長 998 bytes
コンパイル時間 1,654 ms
コンパイル使用メモリ 164,816 KB
実行使用メモリ 7,468 KB
最終ジャッジ日時 2023-09-25 07:45:02
合計ジャッジ時間 5,130 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 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,380 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 28 ms
7,468 KB
testcase_09 AC 102 ms
7,444 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

const int N = 1 << 10;

int n, a[N][N], cnt;

void solve(int xl, int xr, int yl, int yr, bool t) {
    if(xr - xl == 2) {
        if(t) {
            a[xl][yl] = cnt ++;
            a[xl + 1][yl + 1] = cnt ++;
            a[xl + 1][yl] = cnt ++;
            a[xl][yl + 1] = cnt ++;
        }else{
            a[xl][yl] = cnt ++;
            a[xl + 1][yl + 1] = cnt ++;
            a[xl][yl + 1] = cnt ++;
            a[xl + 1][yl] = cnt ++;
        }
        return;
    }
    solve(xl, xl + xr >> 1, yl, yl + yr >> 1, t);
    solve(xl + xr >> 1, xr, yl, yl + yr >> 1, 0);
    solve(xl, xl + xr >> 1, yl + yr >> 1, yr, 0);
    solve(xl + xr >> 1, xr, yl + yr >> 1, yr, t);
}

int main() {
    cin >> n;
    if(n == 1) {
        puts("-1");
        return 0;
    }

    solve(0, 1 << n, 0, 1 << n, 1);

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