結果
問題 | No.2212 One XOR Matrix |
ユーザー |
👑 ![]() |
提出日時 | 2023-02-11 00:25:41 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 59 ms / 2,000 ms |
コード長 | 1,593 bytes |
コンパイル時間 | 2,868 ms |
コンパイル使用メモリ | 254,200 KB |
実行使用メモリ | 8,448 KB |
最終ジャッジ日時 | 2024-07-07 17:56:04 |
合計ジャッジ時間 | 4,690 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 8 |
ソースコード
#include <bits/stdc++.h>using namespace std;#define FOR(i,m,n) for(int i=(m);i<(n);++i)#define REP(i,n) FOR(i,0,n)#define ALL(v) (v).begin(),(v).end()using ll = long long;constexpr int INF = 0x3f3f3f3f;constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;constexpr double EPS = 1e-8;constexpr int MOD = 998244353;// constexpr int MOD = 1000000007;constexpr int DY4[]{1, 0, -1, 0}, DX4[]{0, -1, 0, 1};constexpr int DY8[]{1, 1, 0, -1, -1, -1, 0, 1};constexpr int DX8[]{0, -1, -1, -1, 0, 1, 1, 1};template <typename T, typename U>inline bool chmax(T& a, U b) { return a < b ? (a = b, true) : false; }template <typename T, typename U>inline bool chmin(T& a, U b) { return a > b ? (a = b, true) : false; }struct IOSetup {IOSetup() {std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);std::cout << fixed << setprecision(20);}} iosetup;int main() {int n; cin >> n;if (n == 1) {cout << "-1\n";return 0;}vector<vector<int>> a{{7, 14, 0, 8},{4, 12, 2, 11},{15, 9, 6, 1},{13, 10, 5, 3}};FOR(m, 2, n) {vector b(2 << m, vector(2 << m, 0));REP(i, 1 << m) copy(ALL(a[i]), b[i].begin());REP(i, 1 << m) REP(j, 1 << m) b[(1 << m) + i][(1 << m) + j] = a[i][j] + (1 << (m * 2));REP(i, 1 << m) iota(next(b[i].begin(), 1 << m), b[i].end(), (2 << (m * 2)) + (1 << m) * i);REP(i, 1 << m) iota(b[(1 << m) + i].begin(), next(b[(1 << m) + i].begin(), 1 << m), (3 << (m * 2)) + (1 << m) * i);a.swap(b);}REP(i, 1 << n) REP(j, 1 << n) cout << a[i][j] << " \n"[j + 1 == (1 << n)];return 0;}