結果
問題 | No.2212 One XOR Matrix |
ユーザー |
|
提出日時 | 2023-02-11 04:48:54 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 109 ms / 2,000 ms |
コード長 | 1,140 bytes |
コンパイル時間 | 1,975 ms |
コンパイル使用メモリ | 178,576 KB |
実行使用メモリ | 20,992 KB |
最終ジャッジ日時 | 2024-07-07 21:01:02 |
合計ジャッジ時間 | 3,608 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 8 |
ソースコード
#include <bits/stdc++.h>using namespace std;using Vi = vector<int>;using VVi = std::vector<vector<int>> ;int main () {int N;cin >> N;if (N == 1) {cout << -1 << endl;return 0;}VVi ans1 = {{ 7, 14, 0, 8},{ 4, 12, 2, 11},{15, 9, 6, 1},{13, 10, 5, 3}};VVi ans0 = {{ 7, 14, 1, 8},{ 4, 13, 2, 11},{15, 9, 6, 0},{12, 10, 5, 3}};for (int i = 3; i <= N; i ++) {VVi A0((1 << i), Vi(1 << i)), A1((1 << i), Vi(1 << i));for (int a = 0; a < 4; a ++) {int I = a / 2, J = a & 1;int s = a << (i * 2 - 2);int x = (1 << (i - 1));for (int p = 0; p < x; p ++) {for (int q = 0; q < x; q ++) {A0[p + x * I][q + x * J] = s | ans0[p][q];A1[p + x * I][q + x * J] = s | (I == J ? ans1 : ans0)[p][q];}}}ans0 = A0;ans1 = A1;}for (auto& a : ans1) {for (auto& b : a) {cout << b << " ";}cout << endl;}}