Advertisement
wery00

Untitled

Apr 29th, 2021
1,755
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.23 KB | None | 0 0
  1. #pragma GCC optimize("Ofast")
  2. #pragma GCC target("avx,avx2,fma,popcnt")
  3.  
  4. #include <bits/stdc++.h>
  5.  
  6. #define F first
  7. #define S second
  8. #define vec vector
  9. #define pb push_back
  10. #define cld complex<ld>
  11. #define pll pair<ll, ll>
  12. #define pdd pair<ld, ld>
  13. #define umap unordered_map
  14. #define uset unordered_set
  15. #define pii pair<int, int>
  16. #define pnn pair<Node*, Node*>
  17. #define all(m) m.begin(), m.end()
  18. #define uid uniform_int_distribution
  19. #define init(m, x) memset(m, x, sizeof(m));
  20. #define pripii(p) cout << "{" << p.F << ", " << p.S << "} "
  21. #define fast cin.tie(0); cout.tie(0); cin.sync_with_stdio(0); cout.sync_with_stdio(0);
  22. using namespace std;
  23. typedef string str;
  24. typedef long long ll;
  25. typedef long double ld;
  26. typedef unsigned int uint;
  27. typedef unsigned long long ull;
  28. mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
  29. #include<immintrin.h>
  30.  
  31. const int a = 5000, U = a / 256 + 1;
  32. uint A[a][256], B[a][256];
  33.  
  34. int main() {
  35.     fast;
  36.     uid<uint> g1(0, UINT32_MAX);
  37.     for (int q = 0; q < a; q++) {
  38.         for (int w = 0; w < a / 32 + 1; w++) {
  39.             A[q][w] = g1(rnd);
  40.         }
  41.     }
  42.     for (int q = 0; q < a; q++) {
  43.         for (int w = 0; w < a / 32 + 1; w++) {
  44.             B[q][w] = g1(rnd);
  45.         }
  46.     }
  47.     __m256i xA[a][U], xB[a][U];
  48.     for (int q = 0; q < a; q++) {
  49.         for (int w = 0; w < U; w++) {
  50.             xA[q][w] = _mm256_load_si256(reinterpret_cast<const __m256i_u *>(&A[q][w * 8]));
  51.             xB[q][w] = _mm256_load_si256(reinterpret_cast<const __m256i_u *>(&B[q][w * 8]));
  52.         }
  53.     }
  54.     uint ans[a][a / 32 + 1]; init(ans, 0);
  55.     for (int q = 0; q < a; q++) {
  56.         for (int w = 0; w < a; w++) {
  57.             uint tyt = 0;
  58.             __m256i res = _mm256_set_epi64x(0, 0, 0, 0);
  59.             for (int e = 0; e < U; e++) {
  60.                 res = _mm256_xor_si256(res, _mm256_and_si256(xA[q][e], xB[w][e]));
  61.             }
  62.             for (int e = 0; e < 4; e++) {
  63.                 tyt ^= __builtin_parityll(res[e]);
  64.             }
  65.             ans[q][w >> 5] |= tyt << (w & 31);
  66.         }
  67.     }
  68.     for (int q = 0; q < a; q++) {
  69.         for (int w = 0; w < a / 32 + 1; w++) {
  70.             cout << ans[q][w] << " ";
  71.         }
  72.         cout << "\n";
  73.     }
  74. }
  75.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement