結果
問題 | No.2212 One XOR Matrix |
ユーザー |
|
提出日時 | 2023-02-10 22:22:40 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 84 ms / 2,000 ms |
コード長 | 1,431 bytes |
コンパイル時間 | 1,923 ms |
コンパイル使用メモリ | 200,696 KB |
最終ジャッジ日時 | 2025-02-10 12:59:22 |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 8 |
ソースコード
#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"; } } }