結果

問題 No.2212 One XOR Matrix
ユーザー AngrySadEightAngrySadEight
提出日時 2022-11-29 01:28:36
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 102 ms / 2,000 ms
コード長 1,145 bytes
コンパイル時間 597 ms
コンパイル使用メモリ 77,560 KB
実行使用メモリ 7,228 KB
最終ジャッジ日時 2023-09-13 16:56:38
合計ジャッジ時間 3,403 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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