Submission #644594

# Submission time Handle Problem Language Result Execution time Memory
644594 2022-09-25T03:38:30 Z ymm Fortune Telling 2 (JOI14_fortune_telling2) C++17
35 / 100
3000 ms 1896 KB
#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;

/*
__attribute__((optimize("O3,unroll-loops"),target("avx2")))
void up(int x, int y, int z)
{
	Loop (i,0,n) {
		a[i] ^= a[i] <= x? b[i]: 0;
		a[i] ^= a[i] <= y? b[i]: 0;
		a[i] ^= a[i] <= z? b[i]: 0;
	}
}
*/
void up(int, int, int);

asm("\n"
"	.text\n"
"	.p2align 4\n"
"	.globl	_Z2upiii\n"
"	.type	_Z2upiii, @function\n"
"_Z2upiii:\n"
".myLFB9897:\n"
"	.cfi_startproc\n"
"	movl	%esi, %r8d\n"
"	movslq	n(%rip), %rsi\n"
"	testq	%rsi, %rsi\n"
"	jle	.myL41\n"
"	pushq	%rbp\n"
"	.cfi_def_cfa_offset 16\n"
"	.cfi_offset 6, -16\n"
"	leaq	-1(%rsi), %rax\n"
"	movl	%edx, %r9d\n"
"	movq	%rsp, %rbp\n"
"	.cfi_def_cfa_register 6\n"
"	pushq	%rbx\n"
"	.cfi_offset 3, -24\n"
"	cmpq	$6, %rax\n"
"	jbe	.myL20\n"
"	vmovd	%edx, %xmm4\n"
"	vmovd	%edi, %xmm6\n"
"	vmovd	%r8d, %xmm5\n"
"	movq	%rsi, %rdx\n"
"	shrq	$3, %rdx\n"
"	vpbroadcastd	%xmm6, %ymm6\n"
"	vpbroadcastd	%xmm5, %ymm5\n"
"	leaq	a(%rip), %rcx\n"
"	salq	$5, %rdx\n"
"	vpbroadcastd	%xmm4, %ymm4\n"
"	leaq	(%rcx,%rdx), %r11\n"
"	subq	$32, %rdx\n"
"	movq	%rcx, %rax\n"
"	shrq	$5, %rdx\n"
"	leaq	b(%rip), %r10\n"
"	addq	$1, %rdx\n"
"	andl	$3, %edx\n"
"	je	.myL4\n"
"	cmpq	$1, %rdx\n"
"	je	.myL31\n"
"	cmpq	$2, %rdx\n"
"	je	.myL32\n"
"	vmovdqa	(%rcx), %ymm1\n"
"	vmovdqa	(%r10), %ymm0\n"
"	leaq	32+a(%rip), %rax\n"
"	leaq	32+b(%rip), %r10\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"
"	vmovdqa	%ymm0, (%rcx)\n"
".myL32:\n"
"	vmovdqa	(%rax), %ymm1\n"
"	vmovdqa	(%r10), %ymm0\n"
"	addq	$32, %rax\n"
"	addq	$32, %r10\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"
"	vmovdqa	%ymm0, -32(%rax)\n"
".myL31:\n"
"	vmovdqa	(%rax), %ymm1\n"
"	vmovdqa	(%r10), %ymm0\n"
"	addq	$32, %rax\n"
"	addq	$32, %r10\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"
"	vmovdqa	%ymm0, -32(%rax)\n"
"	cmpq	%r11, %rax\n"
"	je	.myL37\n"
".myL4:\n"
"	vmovdqa	(%rax), %ymm1\n"
"	vmovdqa	(%r10), %ymm0\n"
"	leaq	32(%rax), %rdx\n"
"	subq	$-128, %r10\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"
"	vmovdqa	32(%rax), %ymm1\n"
"	vmovdqa	%ymm0, (%rax)\n"
"	vmovdqa	-96(%r10), %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"
"	vmovdqa	64(%rax), %ymm1\n"
"	vmovdqa	%ymm0, 32(%rax)\n"
"	vmovdqa	-64(%r10), %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"
"	vmovdqa	%ymm0, 64(%rax)\n"
"	vmovdqa	64(%rdx), %ymm1\n"
"	vmovdqa	-32(%r10), %ymm0\n"
"	leaq	96(%rdx), %rax\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"
"	vmovdqa	%ymm0, 64(%rdx)\n"
"	cmpq	%r11, %rax\n"
"	jne	.myL4\n"
".myL37:\n"
"	movq	%rsi, %rdx\n"
"	andq	$-8, %rdx\n"
"	movq	%rdx, %rax\n"
"	cmpq	%rdx, %rsi\n"
"	je	.myL45\n"
"	vzeroupper\n"
".myL3:\n"
"	movq	%rsi, %r10\n"
"	subq	%rdx, %r10\n"
"	leaq	-1(%r10), %r11\n"
"	cmpq	$2, %r11\n"
"	jbe	.myL8\n"
"	leaq	(%rcx,%rdx,4), %r11\n"
"	vmovd	%edi, %xmm7\n"
"	leaq	b(%rip), %rbx\n"
"	vmovdqa	(%r11), %xmm3\n"
"	vpshufd	$0, %xmm7, %xmm1\n"
"	vmovdqa	(%rbx,%rdx,4), %xmm0\n"
"	vmovd	%r8d, %xmm7\n"
"	movq	%r10, %rdx\n"
"	vpcmpgtd	%xmm1, %xmm3, %xmm1\n"
"	vpxor	%xmm0, %xmm3, %xmm2\n"
"	andq	$-4, %rdx\n"
"	addq	%rdx, %rax\n"
"	vpblendvb	%xmm1, %xmm3, %xmm2, %xmm2\n"
"	vpshufd	$0, %xmm7, %xmm3\n"
"	vmovd	%r9d, %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"
"	vmovdqa	%xmm0, (%r11)\n"
"	cmpq	%rdx, %r10\n"
"	je	.myL39\n"
".myL8:\n"
"	movl	(%rcx,%rax,4), %edx\n"
"	cmpl	%edi, %edx\n"
"	jg	.myL10\n"
"	leaq	b(%rip), %r10\n"
"	xorl	(%r10,%rax,4), %edx\n"
".myL10:\n"
"	cmpl	%r8d, %edx\n"
"	jg	.myL11\n"
"	leaq	b(%rip), %r10\n"
"	xorl	(%r10,%rax,4), %edx\n"
".myL11:\n"
"	cmpl	%edx, %r9d\n"
"	jge	.myL46\n"
".myL12:\n"
"	leaq	1(%rax), %r10\n"
"	movl	%edx, (%rcx,%rax,4)\n"
"	cmpq	%r10, %rsi\n"
"	jle	.myL39\n"
"	movl	(%rcx,%r10,4), %edx\n"
"	cmpl	%edx, %edi\n"
"	jl	.myL13\n"
"	leaq	b(%rip), %r11\n"
"	xorl	(%r11,%r10,4), %edx\n"
".myL13:\n"
"	cmpl	%edx, %r8d\n"
"	jl	.myL14\n"
"	leaq	b(%rip), %r11\n"
"	xorl	(%r11,%r10,4), %edx\n"
".myL14:\n"
"	cmpl	%edx, %r9d\n"
"	jl	.myL15\n"
"	leaq	b(%rip), %r11\n"
"	xorl	(%r11,%r10,4), %edx\n"
".myL15:\n"
"	addq	$2, %rax\n"
"	movl	%edx, (%rcx,%r10,4)\n"
"	cmpq	%rax, %rsi\n"
"	jle	.myL39\n"
"	movl	(%rcx,%rax,4), %edx\n"
"	cmpl	%edx, %edi\n"
"	jl	.myL17\n"
"	leaq	b(%rip), %rsi\n"
"	xorl	(%rsi,%rax,4), %edx\n"
".myL17:\n"
"	cmpl	%edx, %r8d\n"
"	jl	.myL19\n"
"	leaq	b(%rip), %rsi\n"
"	xorl	(%rsi,%rax,4), %edx\n"
".myL19:\n"
"	cmpl	%edx, %r9d\n"
"	jl	.myL18\n"
"	leaq	b(%rip), %rsi\n"
"	xorl	(%rsi,%rax,4), %edx\n"
".myL18:\n"
"	movl	%edx, (%rcx,%rax,4)\n"
".myL39:\n"
"	movq	-8(%rbp), %rbx\n"
"	leave\n"
"	.cfi_remember_state\n"
"	.cfi_def_cfa 7, 8\n"
"	ret\n"
"	.p2align 4,,10\n"
"	.p2align 3\n"
".myL46:\n"
"	.cfi_restore_state\n"
"	leaq	b(%rip), %r10\n"
"	xorl	(%r10,%rax,4), %edx\n"
"	jmp	.myL12\n"
"	.p2align 4,,10\n"
"	.p2align 3\n"
".myL41:\n"
"	.cfi_def_cfa 7, 8\n"
"	.cfi_restore 3\n"
"	.cfi_restore 6\n"
"	ret\n"
"	.p2align 4,,10\n"
"	.p2align 3\n"
".myL45:\n"
"	.cfi_def_cfa 6, 16\n"
"	.cfi_offset 3, -24\n"
"	.cfi_offset 6, -16\n"
"	vzeroupper\n"
"	movq	-8(%rbp), %rbx\n"
"	leave\n"
"	.cfi_remember_state\n"
"	.cfi_def_cfa 7, 8\n"
"	ret\n"
".myL20:\n"
"	.cfi_restore_state\n"
"	xorl	%edx, %edx\n"
"	xorl	%eax, %eax\n"
"	leaq	a(%rip), %rcx\n"
"	jmp	.myL3\n"
"	.cfi_endproc\n"
".myLFE9897:\n"
"	.size	_Z2upiii, .-_Z2upiii\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];
	}
	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];
	cout << ans << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 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 340 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 212 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 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 340 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 212 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 13 ms 408 KB Output is correct
15 Correct 46 ms 468 KB Output is correct
16 Correct 98 ms 548 KB Output is correct
17 Correct 167 ms 596 KB Output is correct
18 Correct 181 ms 596 KB Output is correct
19 Correct 175 ms 628 KB Output is correct
20 Correct 166 ms 624 KB Output is correct
21 Correct 170 ms 636 KB Output is correct
22 Correct 164 ms 620 KB Output is correct
23 Correct 171 ms 624 KB Output is correct
24 Correct 165 ms 628 KB Output is correct
25 Correct 167 ms 596 KB Output is correct
26 Correct 143 ms 468 KB Output is correct
27 Correct 166 ms 620 KB Output is correct
28 Correct 166 ms 628 KB Output is correct
29 Correct 165 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 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 340 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 212 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 13 ms 408 KB Output is correct
15 Correct 46 ms 468 KB Output is correct
16 Correct 98 ms 548 KB Output is correct
17 Correct 167 ms 596 KB Output is correct
18 Correct 181 ms 596 KB Output is correct
19 Correct 175 ms 628 KB Output is correct
20 Correct 166 ms 624 KB Output is correct
21 Correct 170 ms 636 KB Output is correct
22 Correct 164 ms 620 KB Output is correct
23 Correct 171 ms 624 KB Output is correct
24 Correct 165 ms 628 KB Output is correct
25 Correct 167 ms 596 KB Output is correct
26 Correct 143 ms 468 KB Output is correct
27 Correct 166 ms 620 KB Output is correct
28 Correct 166 ms 628 KB Output is correct
29 Correct 165 ms 596 KB Output is correct
30 Correct 225 ms 392 KB Output is correct
31 Correct 997 ms 700 KB Output is correct
32 Correct 2117 ms 1108 KB Output is correct
33 Execution timed out 3074 ms 1896 KB Time limit exceeded
34 Halted 0 ms 0 KB -