結果

問題 No.1901 bitwise xor convolution (characteristic 2)
ユーザー risujirohrisujiroh
提出日時 2022-04-12 23:22:33
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,070 ms / 4,000 ms
コード長 1,311 bytes
コンパイル時間 1,983 ms
コンパイル使用メモリ 207,128 KB
実行使用メモリ 68,316 KB
最終ジャッジ日時 2023-08-23 08:55:03
合計ジャッジ時間 9,673 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

int main() {
  using namespace std;
  cin.tie(nullptr)->sync_with_stdio(false);

  int n;
  cin >> n;
  vector<array<unsigned, 32>> a(1 << n);
  vector<array<unsigned, 32>> b(1 << n);
  for (auto&& f : a) {
    for (unsigned& e : f) { cin >> e; }
  }
  for (auto&& f : b) {
    for (unsigned& e : f) { cin >> e; }
  }

  for (int s = 1; s < 1 << n; s <<= 1) {
    for (int o = 0; o < 1 << n; o += s << 1) {
      for (int i = o, j = o + s; j < o + (s << 1); ++i, ++j) {
        for (int k = 0; k <= 31; ++k) {
          tie(a[i][k], a[j][k]) = pair(a[i][k] + a[j][k], a[i][k] - a[j][k]);
          tie(b[i][k], b[j][k]) = pair(b[i][k] + b[j][k], b[i][k] - b[j][k]);
        }
      }
    }
  }

  vector<array<unsigned, 63>> c(1 << n);

  for (int i = 0; i < 1 << n; ++i) {
    for (int s = 0; s <= 31; ++s) {
      for (int t = 0; t <= 31; ++t) { c[i][s + t] += a[i][s] * b[i][t]; }
    }
  }

  for (int s = 1; s < 1 << n; s <<= 1) {
    for (int o = 0; o < 1 << n; o += s << 1) {
      for (int i = o, j = o + s; j < o + (s << 1); ++i, ++j) {
        for (int k = 0; k <= 62; ++k) { tie(c[i][k], c[j][k]) = pair(c[i][k] + c[j][k], c[i][k] - c[j][k]); }
      }
    }
  }

  for (auto&& f : c) {
    for (int i = 0; i <= 62; ++i) { cout << (f[i] >> n & 1) << " \n"[i == 62]; }
  }
}
0