結果

問題 No.2212 One XOR Matrix
ユーザー otoshigootoshigo
提出日時 2023-02-10 22:22:40
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 87 ms / 2,000 ms
コード長 1,431 bytes
コンパイル時間 2,491 ms
コンパイル使用メモリ 207,776 KB
実行使用メモリ 13,356 KB
最終ジャッジ日時 2023-09-21 23:36:55
合計ジャッジ時間 5,176 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
template<class T> bool chmax(T &a, T b){if (a < b){a = b;return true;} else return false;}
template<class T> bool chmin(T &a, T b){if (a > b){a = b;return true;} else return false;}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin>>n;
    if(n==1){
        cout<<-1<<"\n";
    }else{
        vector<vector<int>>X={{7,14,0,8},{4,12,2,11},{15,9,6,1},{13,10,5,3}};
        vector<vector<int>>Y={{0,1,2,3},{4,5,6,7},{8,9,10,11},{12,13,14,15}};
        for(int t=2;t<n;t++){
            int l=X.size();
            vector<vector<int>>Z(2*l,vector<int>(2*l)),W(2*l,vector<int>(2*l));
            rep(i,l)rep(j,l){
                Z[i][j]=X[i][j];
                Z[i+l][j+l]=X[i][j]^(1<<(2*t))^(1<<(2*t+1));
                Z[i+l][j]=Y[i][j]^(1<<(2*t));
                Z[i][j+l]=Y[i][j]^(1<<(2*t+1));
                W[i][j]=Y[i][j];
                W[i+l][j+l]=Y[i][j]^(1<<(2*t))^(1<<(2*t+1));
                W[i+l][j]=Y[i][j]^(1<<(2*t));
                W[i][j+l]=Y[i][j]^(1<<(2*t+1));
            }
            swap(X,Z);
            swap(Y,W);
        }
        int l=X.size();
        rep(i,l){
            rep(j,l)cout<<X[i][j]<<" ";
            cout<<"\n";
        }
    }
}
0