結果

問題 No.2212 One XOR Matrix
コンテスト
ユーザー srjywrdnprkt
提出日時 2023-05-05 09:28:44
言語 C++17
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 53 ms / 2,000 ms
コード長 996 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 807 ms
コンパイル使用メモリ 133,320 KB
実行使用メモリ 7,552 KB
最終ジャッジ日時 2026-06-30 12:04:05
合計ジャッジ時間 2,789 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 8
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <queue>
#include <algorithm>
#include <numeric>
#include <deque>
#include <complex>
#include <cassert>

using namespace std;
using ll = long long;

int main(){

    int N, M;
    cin >> N;
    M = 1<<N;

    if (N == 1){
        cout << -1 << endl;
        return 0;
    }

    vector<vector<int>> a(M, vector<int>(M));

    for (int i=0; i<M; i++){
        for (int j=0; j<M/2; j++) a[i][j] += 1;
    }
    for (int i=0; i<M/2; i++){
        a[i][i] -= 1;
        a[i+M/2][i+M/2] += 1;
    }

    for (int i=0; i<M/2; i++){
        for (int j=0; j<M/2; j++){
            a[i][j+M/2] += (i*M/2+j)*2;
            a[i+M/2][j] += (i*M/2+j)*2;
            a[i][j] += M*M/2 + (i*M/2+j)*2;
            a[i+M/2][j+M/2] += M*M/2 + (i*M/2+j)*2;
        }
    }

    for (int i=0; i<M; i++){
        for (int j=0; j<M; j++) cout << a[i][j] << " ";
        cout << endl;
    }

    return 0;
}
0