#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'010;
int a[N], b[N];
int n;
/*
void up(int x)
{
Loop (i,0,n)
a[i] ^= a[i] <= x? b[i]: 0;
}
*/
void up(int);
asm("\n"
" .text\n"
" .p2align 4\n"
" .globl _Z2upi\n"
" .type _Z2upi, @function\n"
"_Z2upi:\n"
".myLFB9703:\n"
" .cfi_startproc\n"
" movl %edi, %r8d\n"
" movslq n(%rip), %rdi\n"
" testq %rdi, %rdi\n"
" jle .myL53\n"
" leaq -1(%rdi), %rax\n"
" cmpq $6, %rax\n"
" jbe .myL14\n"
" movq %rdi, %rcx\n"
" leaq a(%rip), %rsi\n"
" vmovd %r8d, %xmm3\n"
" shrq $3, %rcx\n"
" vpbroadcastd %xmm3, %ymm3\n"
" movq %rsi, %rax\n"
" salq $5, %rcx\n"
" leaq b(%rip), %rdx\n"
" leaq (%rsi,%rcx), %r9\n"
" subq $32, %rcx\n"
" shrq $5, %rcx\n"
" addq $1, %rcx\n"
" andl $7, %ecx\n"
" je .myL4\n"
" cmpq $1, %rcx\n"
" je .myL37\n"
" cmpq $2, %rcx\n"
" je .myL38\n"
" cmpq $3, %rcx\n"
" je .myL39\n"
" cmpq $4, %rcx\n"
" je .myL40\n"
" cmpq $5, %rcx\n"
" je .myL41\n"
" cmpq $6, %rcx\n"
" jne .myL55\n"
".myL42:\n"
" vmovdqa (%rax), %ymm1\n"
" vpxor (%rdx), %ymm1, %ymm0\n"
" addq $32, %rax\n"
" addq $32, %rdx\n"
" vpcmpgtd %ymm3, %ymm1, %ymm2\n"
" vpblendvb %ymm2, %ymm1, %ymm0, %ymm0\n"
" vmovdqa %ymm0, -32(%rax)\n"
".myL41:\n"
" vmovdqa (%rax), %ymm1\n"
" vpxor (%rdx), %ymm1, %ymm0\n"
" addq $32, %rax\n"
" addq $32, %rdx\n"
" vpcmpgtd %ymm3, %ymm1, %ymm2\n"
" vpblendvb %ymm2, %ymm1, %ymm0, %ymm0\n"
" vmovdqa %ymm0, -32(%rax)\n"
".myL40:\n"
" vmovdqa (%rax), %ymm1\n"
" vpxor (%rdx), %ymm1, %ymm0\n"
" addq $32, %rax\n"
" addq $32, %rdx\n"
" vpcmpgtd %ymm3, %ymm1, %ymm2\n"
" vpblendvb %ymm2, %ymm1, %ymm0, %ymm0\n"
" vmovdqa %ymm0, -32(%rax)\n"
".myL39:\n"
" vmovdqa (%rax), %ymm1\n"
" vpxor (%rdx), %ymm1, %ymm0\n"
" addq $32, %rax\n"
" addq $32, %rdx\n"
" vpcmpgtd %ymm3, %ymm1, %ymm2\n"
" vpblendvb %ymm2, %ymm1, %ymm0, %ymm0\n"
" vmovdqa %ymm0, -32(%rax)\n"
".myL38:\n"
" vmovdqa (%rax), %ymm1\n"
" vpxor (%rdx), %ymm1, %ymm0\n"
" addq $32, %rax\n"
" addq $32, %rdx\n"
" vpcmpgtd %ymm3, %ymm1, %ymm2\n"
" vpblendvb %ymm2, %ymm1, %ymm0, %ymm0\n"
" vmovdqa %ymm0, -32(%rax)\n"
".myL37:\n"
" vmovdqa (%rax), %ymm1\n"
" vpxor (%rdx), %ymm1, %ymm0\n"
" addq $32, %rax\n"
" addq $32, %rdx\n"
" vpcmpgtd %ymm3, %ymm1, %ymm2\n"
" vpblendvb %ymm2, %ymm1, %ymm0, %ymm0\n"
" vmovdqa %ymm0, -32(%rax)\n"
" cmpq %r9, %rax\n"
" je .myL51\n"
".myL4:\n"
" vmovdqa (%rax), %ymm1\n"
" vpxor (%rdx), %ymm1, %ymm0\n"
" leaq 32(%rax), %rcx\n"
" addq $256, %rdx\n"
" vpcmpgtd %ymm3, %ymm1, %ymm2\n"
" vpblendvb %ymm2, %ymm1, %ymm0, %ymm0\n"
" vmovdqa 32(%rax), %ymm1\n"
" vmovdqa %ymm0, (%rax)\n"
" vpxor -224(%rdx), %ymm1, %ymm0\n"
" vpcmpgtd %ymm3, %ymm1, %ymm2\n"
" vpblendvb %ymm2, %ymm1, %ymm0, %ymm0\n"
" vmovdqa 64(%rax), %ymm1\n"
" vmovdqa %ymm0, 32(%rax)\n"
" vpxor -192(%rdx), %ymm1, %ymm0\n"
" vpcmpgtd %ymm3, %ymm1, %ymm2\n"
" vpblendvb %ymm2, %ymm1, %ymm0, %ymm0\n"
" vmovdqa %ymm0, 64(%rax)\n"
" vmovdqa 64(%rcx), %ymm1\n"
" vpxor -160(%rdx), %ymm1, %ymm0\n"
" leaq 224(%rcx), %rax\n"
" vpcmpgtd %ymm3, %ymm1, %ymm2\n"
" vpblendvb %ymm2, %ymm1, %ymm0, %ymm0\n"
" vmovdqa 96(%rcx), %ymm1\n"
" vmovdqa %ymm0, 64(%rcx)\n"
" vpxor -128(%rdx), %ymm1, %ymm0\n"
" vpcmpgtd %ymm3, %ymm1, %ymm2\n"
" vpblendvb %ymm2, %ymm1, %ymm0, %ymm0\n"
" vmovdqa 128(%rcx), %ymm1\n"
" vmovdqa %ymm0, 96(%rcx)\n"
" vpxor -96(%rdx), %ymm1, %ymm0\n"
" vpcmpgtd %ymm3, %ymm1, %ymm2\n"
" vpblendvb %ymm2, %ymm1, %ymm0, %ymm0\n"
" vmovdqa 160(%rcx), %ymm1\n"
" vmovdqa %ymm0, 128(%rcx)\n"
" vpxor -64(%rdx), %ymm1, %ymm0\n"
" vpcmpgtd %ymm3, %ymm1, %ymm2\n"
" vpblendvb %ymm2, %ymm1, %ymm0, %ymm0\n"
" vmovdqa 192(%rcx), %ymm1\n"
" vmovdqa %ymm0, 160(%rcx)\n"
" vpxor -32(%rdx), %ymm1, %ymm0\n"
" vpcmpgtd %ymm3, %ymm1, %ymm2\n"
" vpblendvb %ymm2, %ymm1, %ymm0, %ymm0\n"
" vmovdqa %ymm0, 192(%rcx)\n"
" cmpq %r9, %rax\n"
" jne .myL4\n"
".myL51:\n"
" movq %rdi, %rdx\n"
" andq $-8, %rdx\n"
" movq %rdx, %rax\n"
" cmpq %rdx, %rdi\n"
" je .myL56\n"
" vzeroupper\n"
".myL3:\n"
" movq %rdi, %rcx\n"
" subq %rdx, %rcx\n"
" leaq -1(%rcx), %r9\n"
" cmpq $2, %r9\n"
" jbe .myL8\n"
" leaq (%rsi,%rdx,4), %r9\n"
" vmovd %r8d, %xmm4\n"
" leaq b(%rip), %r10\n"
" vmovdqa (%r9), %xmm2\n"
" vpshufd $0, %xmm4, %xmm0\n"
" vpxor (%r10,%rdx,4), %xmm2, %xmm1\n"
" movq %rcx, %rdx\n"
" andq $-4, %rdx\n"
" vpcmpgtd %xmm0, %xmm2, %xmm0\n"
" addq %rdx, %rax\n"
" vpblendvb %xmm0, %xmm2, %xmm1, %xmm0\n"
" vmovdqa %xmm0, (%r9)\n"
" cmpq %rdx, %rcx\n"
" je .myL53\n"
".myL8:\n"
" movl (%rsi,%rax,4), %edx\n"
" cmpl %r8d, %edx\n"
" jle .myL57\n"
".myL10:\n"
" movl %edx, (%rsi,%rax,4)\n"
" leaq 1(%rax), %rdx\n"
" cmpq %rdx, %rdi\n"
" jle .myL53\n"
" movl (%rsi,%rdx,4), %ecx\n"
" cmpl %ecx, %r8d\n"
" jl .myL11\n"
" leaq b(%rip), %r9\n"
" xorl (%r9,%rdx,4), %ecx\n"
".myL11:\n"
" addq $2, %rax\n"
" movl %ecx, (%rsi,%rdx,4)\n"
" cmpq %rax, %rdi\n"
" jle .myL53\n"
" movl (%rsi,%rax,4), %edx\n"
" cmpl %edx, %r8d\n"
" jl .myL13\n"
" leaq b(%rip), %rcx\n"
" xorl (%rcx,%rax,4), %edx\n"
".myL13:\n"
" movl %edx, (%rsi,%rax,4)\n"
" ret\n"
" .p2align 4,,10\n"
" .p2align 3\n"
".myL53:\n"
" ret\n"
" .p2align 4,,10\n"
" .p2align 3\n"
".myL57:\n"
" leaq b(%rip), %rcx\n"
" xorl (%rcx,%rax,4), %edx\n"
" jmp .myL10\n"
" .p2align 4,,10\n"
" .p2align 3\n"
".myL55:\n"
" vmovdqa (%rsi), %ymm1\n"
" vpxor (%rdx), %ymm1, %ymm0\n"
" leaq 32+a(%rip), %rax\n"
" leaq 32+b(%rip), %rdx\n"
" vpcmpgtd %ymm3, %ymm1, %ymm2\n"
" vpblendvb %ymm2, %ymm1, %ymm0, %ymm0\n"
" vmovdqa %ymm0, (%rsi)\n"
" jmp .myL42\n"
" .p2align 4,,10\n"
" .p2align 3\n"
".myL56:\n"
" vzeroupper\n"
" ret\n"
".myL14:\n"
" xorl %edx, %edx\n"
" xorl %eax, %eax\n"
" leaq a(%rip), %rsi\n"
" jmp .myL3\n"
" .cfi_endproc\n"
".myLFE9703:\n"
" .size _Z2upi, .-_Z2upi\n"
);
int main()
{
cin.tie(0) -> sync_with_stdio(false);
int q;
cin >> n >> q;
Loop (i,0,n) {
cin >> a[i] >> b[i];
b[i] ^= a[i];
}
while (q--) {
int t;
cin >> t;
up(t);
}
ll ans = 0;
Loop (i,0,n)
ans += a[i];
cout << ans << '\n';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
212 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 |
212 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 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
212 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 |
212 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 |
17 ms |
412 KB |
Output is correct |
15 |
Correct |
67 ms |
484 KB |
Output is correct |
16 |
Correct |
141 ms |
548 KB |
Output is correct |
17 |
Correct |
244 ms |
620 KB |
Output is correct |
18 |
Correct |
233 ms |
596 KB |
Output is correct |
19 |
Correct |
267 ms |
656 KB |
Output is correct |
20 |
Correct |
233 ms |
624 KB |
Output is correct |
21 |
Correct |
255 ms |
624 KB |
Output is correct |
22 |
Correct |
247 ms |
628 KB |
Output is correct |
23 |
Correct |
234 ms |
596 KB |
Output is correct |
24 |
Correct |
231 ms |
524 KB |
Output is correct |
25 |
Correct |
246 ms |
620 KB |
Output is correct |
26 |
Correct |
201 ms |
468 KB |
Output is correct |
27 |
Correct |
236 ms |
624 KB |
Output is correct |
28 |
Correct |
239 ms |
620 KB |
Output is correct |
29 |
Correct |
237 ms |
620 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
212 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 |
212 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 |
17 ms |
412 KB |
Output is correct |
15 |
Correct |
67 ms |
484 KB |
Output is correct |
16 |
Correct |
141 ms |
548 KB |
Output is correct |
17 |
Correct |
244 ms |
620 KB |
Output is correct |
18 |
Correct |
233 ms |
596 KB |
Output is correct |
19 |
Correct |
267 ms |
656 KB |
Output is correct |
20 |
Correct |
233 ms |
624 KB |
Output is correct |
21 |
Correct |
255 ms |
624 KB |
Output is correct |
22 |
Correct |
247 ms |
628 KB |
Output is correct |
23 |
Correct |
234 ms |
596 KB |
Output is correct |
24 |
Correct |
231 ms |
524 KB |
Output is correct |
25 |
Correct |
246 ms |
620 KB |
Output is correct |
26 |
Correct |
201 ms |
468 KB |
Output is correct |
27 |
Correct |
236 ms |
624 KB |
Output is correct |
28 |
Correct |
239 ms |
620 KB |
Output is correct |
29 |
Correct |
237 ms |
620 KB |
Output is correct |
30 |
Correct |
302 ms |
340 KB |
Output is correct |
31 |
Correct |
1444 ms |
708 KB |
Output is correct |
32 |
Correct |
2956 ms |
1108 KB |
Output is correct |
33 |
Execution timed out |
3057 ms |
6856 KB |
Time limit exceeded |
34 |
Halted |
0 ms |
0 KB |
- |