結果

問題 No.2212 One XOR Matrix
ユーザー 👑 emthrmemthrm
提出日時 2023-02-11 00:25:41
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 70 ms / 2,000 ms
コード長 1,593 bytes
コンパイル時間 2,998 ms
コンパイル使用メモリ 251,092 KB
実行使用メモリ 8,276 KB
最終ジャッジ日時 2023-09-22 01:03:17
合計ジャッジ時間 5,873 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#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;
}
0