結果
問題 | No.1901 bitwise xor convolution (characteristic 2) |
ユーザー | 👑 hos.lyric |
提出日時 | 2022-04-12 23:46:16 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,699 bytes |
コンパイル時間 | 2,087 ms |
コンパイル使用メモリ | 127,640 KB |
実行使用メモリ | 62,024 KB |
最終ジャッジ日時 | 2024-06-01 06:54:02 |
合計ジャッジ時間 | 4,994 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 3 ms
9,552 KB |
testcase_01 | AC | 3 ms
9,556 KB |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
ソースコード
#pragma GCC optimize ("Ofast") #pragma GCC optimize ("unroll-loops") #pragma GCC target ("avx") #include <cassert> #include <cmath> #include <cstdint> #include <cstdio> #include <cstdlib> #include <cstring> #include <algorithm> #include <bitset> #include <complex> #include <deque> #include <functional> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <string> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> using namespace std; using Int = long long; template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; }; template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; } template <class T> bool chmin(T &t, const T &f) { if (t > f) { t = f; return true; } return false; } template <class T> bool chmax(T &t, const T &f) { if (t < f) { t = f; return true; } return false; } #pragma GCC target("pclmul", "sse2", "sse4.1") #include <emmintrin.h> #include <smmintrin.h> #include <wmmintrin.h> __int64_t clmul(__int64_t x, __int64_t y) { __m128i x_ = _mm_set_epi64x(0, x); __m128i y_ = _mm_set_epi64x(0, y); __m128i z_ = _mm_clmulepi64_si128(x_, y_, 0); return _mm_extract_epi64(z_, 0); } using UInt = unsigned long long; char buf[110]; UInt readPoly() { fgets(buf, sizeof(buf), stdin); UInt ret = 0; for (int e = 0; e < 32; ++e) { ret |= (buf[e << 1] - '0') << e; } return ret; } /* (a0 b0 + a1 b1), (a0 b1 + a1 b0) (a0 + a1) (b0 + b1), (a0 b1 + a1 b0) (a0 + a1) (b0 + b1), ((a0 + a1) b1 + a1 (b0 + b1)) */ constexpr int MAX_N = 17; int N; UInt A[1 << MAX_N]; UInt B[1 << MAX_N]; UInt C[1 << MAX_N]; UInt zas[1 << MAX_N][MAX_N + 1]; UInt zbs[1 << MAX_N][MAX_N + 1]; UInt zcs[1 << MAX_N][MAX_N + 1]; int main() { for (; fgets(buf, sizeof(buf), stdin); ) { N = atoi(buf); for (int h = 0; h < 1 << N; ++h) A[h] = readPoly(); for (int h = 0; h < 1 << N; ++h) B[h] = readPoly(); for (int i = 0; i < N; ++i) for (int h = 0; h < 1 << N; ++h) if (!(h & 1 << i)) A[h] ^= A[h | 1 << i]; for (int i = 0; i < N; ++i) for (int h = 0; h < 1 << N; ++h) if (!(h & 1 << i)) B[h] ^= B[h | 1 << i]; #ifdef LOCAL memset(C, 0, sizeof(C)); memset(zas, 0, sizeof(zas)); memset(zbs, 0, sizeof(zbs)); memset(zcs, 0, sizeof(zcs)); #endif for (int h = 0; h < 1 << N; ++h) zas[h][__builtin_popcount(h)] = A[h]; for (int h = 0; h < 1 << N; ++h) zbs[h][__builtin_popcount(h)] = B[h]; for (int i = 0; i < N; ++i) for (int h = 0; h < 1 << N; ++h) if (!(h & 1 << i)) { const int hh = h | 1 << i; for (int k = 0; k <= N; ++k) zas[hh][k] ^= zas[h][k]; } for (int i = 0; i < N; ++i) for (int h = 0; h < 1 << N; ++h) if (!(h & 1 << i)) { const int hh = h | 1 << i; for (int k = 0; k <= N; ++k) zbs[hh][k] ^= zbs[h][k]; } for (int h = 0; h < 1 << N; ++h) { for (int k = 0; k <= N; ++k) for (int l = 0; l <= N - k; ++l) { zcs[h][k + l] ^= clmul(zas[h][k], zbs[h][l]); } } for (int i = 0; i < N; ++i) for (int h = 0; h < 1 << N; ++h) if (!(h & 1 << i)) { const int hh = h | 1 << i; for (int k = 0; k <= N; ++k) zcs[hh][k] ^= zcs[h][k]; } for (int h = 0; h < 1 << N; ++h) C[h] = zcs[h][__builtin_popcount(h)]; for (int i = 0; i < N; ++i) for (int h = 0; h < 1 << N; ++h) if (!(h & 1 << i)) C[h] ^= C[h | 1 << i]; for (int h = 0; h < 1 << N; ++h) { for (int e = 0; e < 63; ++e) { if (e) putchar(' '); putchar('0' + (C[h] >> e & 1)); } puts(""); } } return 0; }