#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 = 200'032;
const int S = 1024;
int a[N], b[N];
int q[N];
int n;
/*
__attribute__((optimize("O3,unroll-loops"),target("avx2")))
void up(int x, int y, int z, int l, int r)
{
Loop (i,l,r) {
int v = a[i], u = b[i];
v ^= v <= x? u: 0;
v ^= v <= y? u: 0;
v ^= v <= z? u: 0;
a[i] = v;
}
}
*/
void up(int,int,int,int,int);
asm("\n"
" .text\n"
" .p2align 4\n"
" .globl _Z2upiiiii\n"
" .type _Z2upiiiii, @function\n"
"_Z2upiiiii:\n"
".myLFB9703:\n"
" .cfi_startproc\n"
" pushq %rbp\n"
" .cfi_def_cfa_offset 16\n"
" .cfi_offset 6, -16\n"
" movl %edx, %r11d\n"
" movslq %ecx, %rdx\n"
" movq %rsp, %rbp\n"
" .cfi_def_cfa_register 6\n"
" pushq %r15\n"
" pushq %r14\n"
" pushq %r13\n"
" pushq %r12\n"
" pushq %rbx\n"
" .cfi_offset 15, -24\n"
" .cfi_offset 14, -32\n"
" .cfi_offset 13, -40\n"
" .cfi_offset 12, -48\n"
" .cfi_offset 3, -56\n"
" movslq %r8d, %rbx\n"
" cmpq %rbx, %rdx\n"
" jge .myL39\n"
" movl %esi, %r10d\n"
" movq %rbx, %rsi\n"
" movl %edi, %r9d\n"
" movq %rdx, %r14\n"
" subq %rdx, %rsi\n"
" leaq -1(%rsi), %rax\n"
" cmpq $6, %rax\n"
" jbe .myL20\n"
" movq %rsi, %r15\n"
" leaq a(%rip), %r8\n"
" vmovd %r9d, %xmm6\n"
" xorl %eax, %eax\n"
" shrq $3, %r15\n"
" leaq 0(,%rdx,4), %rdi\n"
" leaq b(%rip), %r12\n"
" vmovd %r10d, %xmm5\n"
" salq $5, %r15\n"
" vmovd %r11d, %xmm4\n"
" leaq (%r8,%rdi), %rcx\n"
" leaq -32(%r15), %r13\n"
" addq %r12, %rdi\n"
" vpbroadcastd %xmm6, %ymm6\n"
" shrq $5, %r13\n"
" vpbroadcastd %xmm5, %ymm5\n"
" vpbroadcastd %xmm4, %ymm4\n"
" addq $1, %r13\n"
" andl $3, %r13d\n"
" je .myL4\n"
" cmpq $1, %r13\n"
" je .myL31\n"
" cmpq $2, %r13\n"
" je .myL32\n"
" vmovdqu (%rcx), %ymm1\n"
" vmovdqu (%rdi), %ymm0\n"
" movl $32, %eax\n"
" vpcmpgtd %ymm6, %ymm1, %ymm3\n"
" vpxor %ymm0, %ymm1, %ymm2\n"
" vpblendvb %ymm3, %ymm1, %ymm2, %ymm2\n"
" vpcmpgtd %ymm5, %ymm2, %ymm3\n"
" vpxor %ymm2, %ymm0, %ymm1\n"
" vpblendvb %ymm3, %ymm2, %ymm1, %ymm1\n"
" vpcmpgtd %ymm4, %ymm1, %ymm2\n"
" vpxor %ymm1, %ymm0, %ymm0\n"
" vpblendvb %ymm2, %ymm1, %ymm0, %ymm0\n"
" vmovdqu %ymm0, (%rcx)\n"
".myL32:\n"
" vmovdqu (%rcx,%rax), %ymm1\n"
" vmovdqu (%rdi,%rax), %ymm0\n"
" vpcmpgtd %ymm6, %ymm1, %ymm3\n"
" vpxor %ymm0, %ymm1, %ymm2\n"
" vpblendvb %ymm3, %ymm1, %ymm2, %ymm2\n"
" vpcmpgtd %ymm5, %ymm2, %ymm3\n"
" vpxor %ymm2, %ymm0, %ymm1\n"
" vpblendvb %ymm3, %ymm2, %ymm1, %ymm1\n"
" vpcmpgtd %ymm4, %ymm1, %ymm2\n"
" vpxor %ymm1, %ymm0, %ymm0\n"
" vpblendvb %ymm2, %ymm1, %ymm0, %ymm0\n"
" vmovdqu %ymm0, (%rcx,%rax)\n"
" addq $32, %rax\n"
".myL31:\n"
" vmovdqu (%rcx,%rax), %ymm1\n"
" vmovdqu (%rdi,%rax), %ymm0\n"
" vpcmpgtd %ymm6, %ymm1, %ymm3\n"
" vpxor %ymm0, %ymm1, %ymm2\n"
" vpblendvb %ymm3, %ymm1, %ymm2, %ymm2\n"
" vpcmpgtd %ymm5, %ymm2, %ymm3\n"
" vpxor %ymm2, %ymm0, %ymm1\n"
" vpblendvb %ymm3, %ymm2, %ymm1, %ymm1\n"
" vpcmpgtd %ymm4, %ymm1, %ymm2\n"
" vpxor %ymm1, %ymm0, %ymm0\n"
" vpblendvb %ymm2, %ymm1, %ymm0, %ymm0\n"
" vmovdqu %ymm0, (%rcx,%rax)\n"
" addq $32, %rax\n"
" cmpq %r15, %rax\n"
" je .myL37\n"
".myL4:\n"
" vmovdqu (%rcx,%rax), %ymm1\n"
" vmovdqu (%rdi,%rax), %ymm0\n"
" leaq 32(%rax), %r13\n"
" vpcmpgtd %ymm6, %ymm1, %ymm3\n"
" vpxor %ymm0, %ymm1, %ymm2\n"
" vpblendvb %ymm3, %ymm1, %ymm2, %ymm2\n"
" vpcmpgtd %ymm5, %ymm2, %ymm3\n"
" vpxor %ymm2, %ymm0, %ymm1\n"
" vpblendvb %ymm3, %ymm2, %ymm1, %ymm1\n"
" vpcmpgtd %ymm4, %ymm1, %ymm2\n"
" vpxor %ymm1, %ymm0, %ymm0\n"
" vpblendvb %ymm2, %ymm1, %ymm0, %ymm0\n"
" vmovdqu 32(%rcx,%rax), %ymm1\n"
" vmovdqu %ymm0, (%rcx,%rax)\n"
" vmovdqu 32(%rdi,%rax), %ymm0\n"
" vpcmpgtd %ymm6, %ymm1, %ymm3\n"
" vpxor %ymm0, %ymm1, %ymm2\n"
" vpblendvb %ymm3, %ymm1, %ymm2, %ymm2\n"
" vpcmpgtd %ymm5, %ymm2, %ymm3\n"
" vpxor %ymm2, %ymm0, %ymm1\n"
" vpblendvb %ymm3, %ymm2, %ymm1, %ymm1\n"
" vpcmpgtd %ymm4, %ymm1, %ymm2\n"
" vpxor %ymm1, %ymm0, %ymm0\n"
" vpblendvb %ymm2, %ymm1, %ymm0, %ymm0\n"
" vmovdqu 64(%rcx,%rax), %ymm1\n"
" vmovdqu %ymm0, 32(%rcx,%rax)\n"
" vmovdqu 64(%rdi,%rax), %ymm0\n"
" vpcmpgtd %ymm6, %ymm1, %ymm3\n"
" vpxor %ymm0, %ymm1, %ymm2\n"
" vpblendvb %ymm3, %ymm1, %ymm2, %ymm2\n"
" vpcmpgtd %ymm5, %ymm2, %ymm3\n"
" vpxor %ymm2, %ymm0, %ymm1\n"
" vpblendvb %ymm3, %ymm2, %ymm1, %ymm1\n"
" vpcmpgtd %ymm4, %ymm1, %ymm2\n"
" vpxor %ymm1, %ymm0, %ymm0\n"
" vpblendvb %ymm2, %ymm1, %ymm0, %ymm0\n"
" vmovdqu %ymm0, 64(%rcx,%rax)\n"
" vmovdqu 64(%rcx,%r13), %ymm1\n"
" leaq 96(%r13), %rax\n"
" vmovdqu 64(%rdi,%r13), %ymm0\n"
" vpcmpgtd %ymm6, %ymm1, %ymm3\n"
" vpxor %ymm0, %ymm1, %ymm2\n"
" vpblendvb %ymm3, %ymm1, %ymm2, %ymm2\n"
" vpcmpgtd %ymm5, %ymm2, %ymm3\n"
" vpxor %ymm2, %ymm0, %ymm1\n"
" vpblendvb %ymm3, %ymm2, %ymm1, %ymm1\n"
" vpcmpgtd %ymm4, %ymm1, %ymm2\n"
" vpxor %ymm1, %ymm0, %ymm0\n"
" vpblendvb %ymm2, %ymm1, %ymm0, %ymm0\n"
" vmovdqu %ymm0, 64(%rcx,%r13)\n"
" cmpq %r15, %rax\n"
" jne .myL4\n"
".myL37:\n"
" movq %rsi, %rax\n"
" andq $-8, %rax\n"
" addq %rax, %rdx\n"
" cmpq %rax, %rsi\n"
" je .myL42\n"
" vzeroupper\n"
".myL3:\n"
" subq %rax, %rsi\n"
" leaq -1(%rsi), %rcx\n"
" cmpq $2, %rcx\n"
" jbe .myL8\n"
" addq %r14, %rax\n"
" vmovd %r9d, %xmm7\n"
" leaq (%r8,%rax,4), %rcx\n"
" vpshufd $0, %xmm7, %xmm1\n"
" vmovdqu (%r12,%rax,4), %xmm0\n"
" movq %rsi, %rax\n"
" vmovdqu (%rcx), %xmm3\n"
" vmovd %r10d, %xmm7\n"
" andq $-4, %rax\n"
" addq %rax, %rdx\n"
" vpcmpgtd %xmm1, %xmm3, %xmm1\n"
" vpxor %xmm0, %xmm3, %xmm2\n"
" vpblendvb %xmm1, %xmm3, %xmm2, %xmm2\n"
" vpshufd $0, %xmm7, %xmm3\n"
" vmovd %r11d, %xmm7\n"
" vpcmpgtd %xmm3, %xmm2, %xmm3\n"
" vpxor %xmm2, %xmm0, %xmm1\n"
" vpblendvb %xmm3, %xmm2, %xmm1, %xmm1\n"
" vpshufd $0, %xmm7, %xmm2\n"
" vpcmpgtd %xmm2, %xmm1, %xmm2\n"
" vpxor %xmm1, %xmm0, %xmm0\n"
" vpblendvb %xmm2, %xmm1, %xmm0, %xmm0\n"
" vmovdqu %xmm0, (%rcx)\n"
" cmpq %rax, %rsi\n"
" je .myL39\n"
".myL8:\n"
" movl (%r8,%rdx,4), %eax\n"
" movl (%r12,%rdx,4), %ecx\n"
" leaq 1(%rdx), %rsi\n"
" xorl %eax, %ecx\n"
" cmpl %r9d, %eax\n"
" cmovle %ecx, %eax\n"
" movl (%r12,%rdx,4), %ecx\n"
" xorl %eax, %ecx\n"
" cmpl %eax, %r10d\n"
" cmovge %ecx, %eax\n"
" movl (%r12,%rdx,4), %ecx\n"
" xorl %eax, %ecx\n"
" cmpl %eax, %r11d\n"
" cmovge %ecx, %eax\n"
" movl %eax, (%r8,%rdx,4)\n"
" cmpq %rsi, %rbx\n"
" jle .myL39\n"
" movl (%r8,%rsi,4), %eax\n"
" movl (%r12,%rsi,4), %ecx\n"
" xorl %eax, %ecx\n"
" cmpl %eax, %r9d\n"
" cmovge %ecx, %eax\n"
" movl (%r12,%rsi,4), %ecx\n"
" xorl %eax, %ecx\n"
" cmpl %eax, %r10d\n"
" cmovge %ecx, %eax\n"
" movl (%r12,%rsi,4), %ecx\n"
" xorl %eax, %ecx\n"
" cmpl %eax, %r11d\n"
" cmovge %ecx, %eax\n"
" addq $2, %rdx\n"
" movl %eax, (%r8,%rsi,4)\n"
" cmpq %rdx, %rbx\n"
" jle .myL39\n"
" movl (%r8,%rdx,4), %eax\n"
" movl (%r12,%rdx,4), %ecx\n"
" movl %eax, %esi\n"
" xorl %ecx, %esi\n"
" cmpl %eax, %r9d\n"
" cmovge %esi, %eax\n"
" movl %eax, %esi\n"
" xorl %ecx, %esi\n"
" cmpl %eax, %r10d\n"
" cmovge %esi, %eax\n"
" xorl %eax, %ecx\n"
" cmpl %eax, %r11d\n"
" cmovge %ecx, %eax\n"
" movl %eax, (%r8,%rdx,4)\n"
".myL39:\n"
" popq %rbx\n"
" popq %r12\n"
" popq %r13\n"
" popq %r14\n"
" popq %r15\n"
" popq %rbp\n"
" .cfi_remember_state\n"
" .cfi_def_cfa 7, 8\n"
" ret\n"
" .p2align 4,,10\n"
" .p2align 3\n"
".myL42:\n"
" .cfi_restore_state\n"
" vzeroupper\n"
" popq %rbx\n"
" popq %r12\n"
" popq %r13\n"
" popq %r14\n"
" popq %r15\n"
" popq %rbp\n"
" .cfi_remember_state\n"
" .cfi_def_cfa 7, 8\n"
" ret\n"
".myL20:\n"
" .cfi_restore_state\n"
" xorl %eax, %eax\n"
" leaq a(%rip), %r8\n"
" leaq b(%rip), %r12\n"
" jmp .myL3\n"
" .cfi_endproc\n"
".myLFE9703:\n"
" .size _Z2upiiiii, .-_Z2upiiiii\n"
);
int main()
{
cin.tie(0) -> sync_with_stdio(false);
int k;
cin >> n >> k;
Loop (i,0,n) {
cin >> a[i] >> b[i];
b[i] ^= a[i];
}
Loop (i,0,k)
cin >> q[i];
for (int l = 0; l < n; l += S) {
int r = min(n, l+S);
for (int i = 0; i < k; i += 3)
up(q[i+0], q[i+1], q[i+2], l, r);
}
ll ans = 0;
Loop (i,0,n)
ans += a[i];
cout << ans << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
14 ms |
568 KB |
Output is correct |
15 |
Correct |
47 ms |
680 KB |
Output is correct |
16 |
Correct |
99 ms |
800 KB |
Output is correct |
17 |
Correct |
168 ms |
972 KB |
Output is correct |
18 |
Correct |
168 ms |
1012 KB |
Output is correct |
19 |
Correct |
176 ms |
1044 KB |
Output is correct |
20 |
Correct |
166 ms |
1044 KB |
Output is correct |
21 |
Correct |
166 ms |
1044 KB |
Output is correct |
22 |
Correct |
170 ms |
1044 KB |
Output is correct |
23 |
Correct |
164 ms |
1048 KB |
Output is correct |
24 |
Correct |
164 ms |
1040 KB |
Output is correct |
25 |
Correct |
165 ms |
980 KB |
Output is correct |
26 |
Correct |
142 ms |
904 KB |
Output is correct |
27 |
Correct |
166 ms |
968 KB |
Output is correct |
28 |
Correct |
165 ms |
1024 KB |
Output is correct |
29 |
Correct |
171 ms |
1048 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
14 ms |
568 KB |
Output is correct |
15 |
Correct |
47 ms |
680 KB |
Output is correct |
16 |
Correct |
99 ms |
800 KB |
Output is correct |
17 |
Correct |
168 ms |
972 KB |
Output is correct |
18 |
Correct |
168 ms |
1012 KB |
Output is correct |
19 |
Correct |
176 ms |
1044 KB |
Output is correct |
20 |
Correct |
166 ms |
1044 KB |
Output is correct |
21 |
Correct |
166 ms |
1044 KB |
Output is correct |
22 |
Correct |
170 ms |
1044 KB |
Output is correct |
23 |
Correct |
164 ms |
1048 KB |
Output is correct |
24 |
Correct |
164 ms |
1040 KB |
Output is correct |
25 |
Correct |
165 ms |
980 KB |
Output is correct |
26 |
Correct |
142 ms |
904 KB |
Output is correct |
27 |
Correct |
166 ms |
968 KB |
Output is correct |
28 |
Correct |
165 ms |
1024 KB |
Output is correct |
29 |
Correct |
171 ms |
1048 KB |
Output is correct |
30 |
Correct |
213 ms |
1424 KB |
Output is correct |
31 |
Correct |
996 ms |
1732 KB |
Output is correct |
32 |
Correct |
1978 ms |
2124 KB |
Output is correct |
33 |
Execution timed out |
3039 ms |
3640 KB |
Time limit exceeded |
34 |
Halted |
0 ms |
0 KB |
- |