Advertisement
wery00

Untitled

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