結果

問題 No.2212 One XOR Matrix
ユーザー 👑 AngrySadEight
提出日時 2022-11-29 01:28:36
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 100 ms / 2,000 ms
コード長 1,145 bytes
コンパイル時間 800 ms
コンパイル使用メモリ 75,392 KB
最終ジャッジ日時 2025-02-09 02:03:18
ジャッジサーバーID
(参考情報)
judge3 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;

int main(){
    int N;
    cin >> N;
    vector<vector<int>> ans((1 << N), vector<int>((1 << N), 0));

    if (N == 1){
        cout << -1 << endl;
        
    }
    else{
        int now = 0;
        for (int i = 0; i < (1 << (N - 1)); i++){
            for (int j = 0; j < (1 << (N - 1)); j++){
                ans[i + (1 << (N - 1))][j + (1 << (N - 1))]++;
                if (i == j){
                    ans[i][j + (1 << (N - 1))]++;
                }
                else{
                    ans[i + (1 << (N - 1))][j]++;
                }
                ans[i][j] += now;
                ans[i + (1 << (N - 1))][j + (1 << (N - 1))] += now;
                ans[i][j + (1 << (N - 1))] += (now + (1 << (2 * N - 1)));
                ans[i + (1 << (N - 1))][j] += (now + (1 << (2 * N - 1)));

                now += 2;
            }
        }
        for (int i = 0; i < (1 << N); i++){
            for (int j = 0; j < (1 << N); j++){
                cout << ans[i][j];
                if (j != (1 << N) - 1) cout << " ";
            }
            cout << "\n";
        }
    }
}
0