This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define Loop(x,l,r) for (ll x = (l); x < (r); ++x)
#define LoopR(x,l,r) for (ll x = (r)-1; x >= (l); --x)
typedef long long ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll , ll > pll;
using namespace std;
const int N = 400'000;
int a[N];
int n;
__attribute__((optimize("O3,unroll-loops"),target("avx2")))
void up(int x, int y, int z)
{
typedef int ymm __attribute__((vector_size(32),aligned(32)));
const auto b = (ymm*)a;
for (int i = 0; i < N/8; i += 2) {
b[i] ^= b[i] <= x? b[i+1]: 0;
b[i] ^= b[i] <= y? b[i+1]: 0;
b[i] ^= b[i] <= z? b[i+1]: 0;
}
}
int main()
{
cin.tie(0) -> sync_with_stdio(false);
int q;
cin >> n >> q;
Loop (i,0,n) {
int x, y;
cin >> x >> y;
y ^= x;
a[(i/8)*16 + i%8] = x;
a[(i/8)*16 + i%8 + 8] = y;
}
int g[3] = {rand(), rand(), rand()};
for (int i = 0; i < q; i += 3) {
int x, y, z;
i+0 < q? cin >> x, 0: (x = 0);
i+1 < q? cin >> y, 0: (y = 0);
i+2 < q? cin >> z, 0: (z = 0);
up(x, y, z);
}
ll ans = 0;
Loop (i,0,n)
ans += a[(i/8)*16 + i%8];
cout << ans << '\n';
}
Compilation message (stderr)
fortune_telling2.cpp: In function 'int main()':
fortune_telling2.cpp:37:6: warning: unused variable 'g' [-Wunused-variable]
37 | int g[3] = {rand(), rand(), rand()};
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |