답안 #644703

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
644703 2022-09-25T06:30:40 Z ymm 운세 보기 2 (JOI14_fortune_telling2) C++17
35 / 100
3000 ms 4340 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'032;
const int S0 = 32767;
const int S1 = 1024;
int a[N], b[N];
unsigned short sa[N], sb[N];
int q[N];
unsigned short sq[N];
int n;

/*
__attribute__((optimize("O3,unroll-loops"),target("avx2")))
void up(unsigned short x, unsigned short y, unsigned short z, int l, int r)
{
	Loop (i,l,r) {
		unsigned short v = sa[i], u = sb[i];
		v ^= v <= x? u: 0;
		v ^= v <= y? u: 0;
		v ^= v <= z? u: 0;
		sa[i] = v;
	}
}
*/
void up(unsigned short, unsigned short, unsigned short, int, int);
asm(" .p2align 4\n.globl	_Z2uptttii\n.type	_Z2uptttii, @function\n_Z2uptttii:\n.myLFB9897:\n.cfi_startproc\nmovl	%edx, %r11d\nmovslq	%r8d, %r8\nmovslq	%ecx, %rdx\ncmpq	%rdx, %r8\njle	.myL135\npushq	%rbp\n.cfi_def_cfa_offset 16\n.cfi_offset 6, -16\nmovl	%edi, %r9d\nmovq	%r8, %rdi\nmovl	%esi, %r10d\nsubq	%rdx, %rdi\nleaq	-1(%rdi), %rax\nmovq	%rsp, %rbp\n.cfi_def_cfa_register 6\npushq	%r15\npushq	%r14\n.cfi_offset 15, -24\n.cfi_offset 14, -32\nmovq	%rdx, %r14\npushq	%r13\npushq	%r12\npushq	%rbx\n.cfi_offset 13, -40\n.cfi_offset 12, -48\n.cfi_offset 3, -56\ncmpq	$14, %rax\njbe	.myL114\nmovq	%rdi, %r15\nleaq	(%rdx,%rdx), %r12\nleaq	sa(%rip), %rsi\nxorl	%eax, %eax\nvmovd	%r9d, %xmm6\nshrq	$4, %r15\nvmovd	%r10d, %xmm5\nvmovd	%r11d, %xmm4\nsalq	$5, %r15\nleaq	sb(%rip), %rbx\nleaq	(%rsi,%r12), %rcx\nleaq	-32(%r15), %r13\nvpbroadcastw	%xmm6, %ymm6\nvpxor	%xmm3, %xmm3, %xmm3\naddq	%rbx, %r12\nshrq	$5, %r13\nvpbroadcastw	%xmm5, %ymm5\nvpbroadcastw	%xmm4, %ymm4\naddq	$1, %r13\nandl	$3, %r13d\nje	.myL86\ncmpq	$1, %r13\nje	.myL125\ncmpq	$2, %r13\nje	.myL126\nvmovdqu	(%rcx), %ymm0\nvmovdqu	(%r12), %ymm1\nmovl	$32, %eax\nvpsubusw	%ymm6, %ymm0, %ymm2\nvpxor	%ymm1, %ymm0, %ymm7\nvpcmpeqw	%ymm3, %ymm2, %ymm2\nvpblendvb	%ymm2, %ymm7, %ymm0, %ymm0\nvpsubusw	%ymm5, %ymm0, %ymm2\nvpxor	%ymm0, %ymm1, %ymm7\nvpcmpeqw	%ymm3, %ymm2, %ymm2\nvpblendvb	%ymm2, %ymm7, %ymm0, %ymm0\nvpsubusw	%ymm4, %ymm0, %ymm2\nvpxor	%ymm0, %ymm1, %ymm1\nvpcmpeqw	%ymm3, %ymm2, %ymm2\nvpblendvb	%ymm2, %ymm1, %ymm0, %ymm0\nvmovdqu	%ymm0, (%rcx)\n.myL126:\nvmovdqu	(%rcx,%rax), %ymm0\nvmovdqu	(%r12,%rax), %ymm1\nvpsubusw	%ymm6, %ymm0, %ymm2\nvpxor	%ymm1, %ymm0, %ymm7\nvpcmpeqw	%ymm3, %ymm2, %ymm2\nvpblendvb	%ymm2, %ymm7, %ymm0, %ymm0\nvpsubusw	%ymm5, %ymm0, %ymm2\nvpxor	%ymm0, %ymm1, %ymm7\nvpcmpeqw	%ymm3, %ymm2, %ymm2\nvpblendvb	%ymm2, %ymm7, %ymm0, %ymm0\nvpsubusw	%ymm4, %ymm0, %ymm2\nvpxor	%ymm0, %ymm1, %ymm1\nvpcmpeqw	%ymm3, %ymm2, %ymm2\nvpblendvb	%ymm2, %ymm1, %ymm0, %ymm0\nvmovdqu	%ymm0, (%rcx,%rax)\naddq	$32, %rax\n.myL125:\nvmovdqu	(%rcx,%rax), %ymm0\nvmovdqu	(%r12,%rax), %ymm1\nvpsubusw	%ymm6, %ymm0, %ymm2\nvpxor	%ymm1, %ymm0, %ymm7\nvpcmpeqw	%ymm3, %ymm2, %ymm2\nvpblendvb	%ymm2, %ymm7, %ymm0, %ymm0\nvpsubusw	%ymm5, %ymm0, %ymm2\nvpxor	%ymm0, %ymm1, %ymm7\nvpcmpeqw	%ymm3, %ymm2, %ymm2\nvpblendvb	%ymm2, %ymm7, %ymm0, %ymm0\nvpsubusw	%ymm4, %ymm0, %ymm2\nvpxor	%ymm0, %ymm1, %ymm1\nvpcmpeqw	%ymm3, %ymm2, %ymm2\nvpblendvb	%ymm2, %ymm1, %ymm0, %ymm0\nvmovdqu	%ymm0, (%rcx,%rax)\naddq	$32, %rax\ncmpq	%r15, %rax\nje	.myL131\n.myL86:\nvmovdqu	(%rcx,%rax), %ymm0\nvmovdqu	(%r12,%rax), %ymm1\nleaq	32(%rax), %r13\nvpsubusw	%ymm6, %ymm0, %ymm2\nvpxor	%ymm1, %ymm0, %ymm7\nvpcmpeqw	%ymm3, %ymm2, %ymm2\nvpblendvb	%ymm2, %ymm7, %ymm0, %ymm0\nvpsubusw	%ymm5, %ymm0, %ymm2\nvpxor	%ymm0, %ymm1, %ymm7\nvpcmpeqw	%ymm3, %ymm2, %ymm2\nvpblendvb	%ymm2, %ymm7, %ymm0, %ymm0\nvpsubusw	%ymm4, %ymm0, %ymm2\nvpxor	%ymm0, %ymm1, %ymm1\nvpcmpeqw	%ymm3, %ymm2, %ymm2\nvpblendvb	%ymm2, %ymm1, %ymm0, %ymm0\nvmovdqu	%ymm0, (%rcx,%rax)\nvmovdqu	32(%rcx,%rax), %ymm0\nvmovdqu	32(%r12,%rax), %ymm1\nvpsubusw	%ymm6, %ymm0, %ymm2\nvpxor	%ymm1, %ymm0, %ymm7\nvpcmpeqw	%ymm3, %ymm2, %ymm2\nvpblendvb	%ymm2, %ymm7, %ymm0, %ymm0\nvpsubusw	%ymm5, %ymm0, %ymm2\nvpxor	%ymm0, %ymm1, %ymm7\nvpcmpeqw	%ymm3, %ymm2, %ymm2\nvpblendvb	%ymm2, %ymm7, %ymm0, %ymm0\nvpsubusw	%ymm4, %ymm0, %ymm2\nvpxor	%ymm0, %ymm1, %ymm1\nvpcmpeqw	%ymm3, %ymm2, %ymm2\nvpblendvb	%ymm2, %ymm1, %ymm0, %ymm0\nvmovdqu	%ymm0, 32(%rcx,%rax)\nvmovdqu	64(%rcx,%rax), %ymm0\nvmovdqu	64(%r12,%rax), %ymm1\nvpsubusw	%ymm6, %ymm0, %ymm2\nvpxor	%ymm1, %ymm0, %ymm7\nvpcmpeqw	%ymm3, %ymm2, %ymm2\nvpblendvb	%ymm2, %ymm7, %ymm0, %ymm0\nvpsubusw	%ymm5, %ymm0, %ymm2\nvpxor	%ymm0, %ymm1, %ymm7\nvpcmpeqw	%ymm3, %ymm2, %ymm2\nvpblendvb	%ymm2, %ymm7, %ymm0, %ymm0\nvpsubusw	%ymm4, %ymm0, %ymm2\nvpxor	%ymm0, %ymm1, %ymm1\nvpcmpeqw	%ymm3, %ymm2, %ymm2\nvpblendvb	%ymm2, %ymm1, %ymm0, %ymm0\nvmovdqu	%ymm0, 64(%rcx,%rax)\nvmovdqu	64(%rcx,%r13), %ymm0\nleaq	96(%r13), %rax\nvmovdqu	64(%r12,%r13), %ymm1\nvpsubusw	%ymm6, %ymm0, %ymm2\nvpxor	%ymm1, %ymm0, %ymm7\nvpcmpeqw	%ymm3, %ymm2, %ymm2\nvpblendvb	%ymm2, %ymm7, %ymm0, %ymm0\nvpsubusw	%ymm5, %ymm0, %ymm2\nvpxor	%ymm0, %ymm1, %ymm7\nvpcmpeqw	%ymm3, %ymm2, %ymm2\nvpblendvb	%ymm2, %ymm7, %ymm0, %ymm0\nvpsubusw	%ymm4, %ymm0, %ymm2\nvpxor	%ymm0, %ymm1, %ymm1\nvpcmpeqw	%ymm3, %ymm2, %ymm2\nvpblendvb	%ymm2, %ymm1, %ymm0, %ymm0\nvmovdqu	%ymm0, 64(%rcx,%r13)\ncmpq	%r15, %rax\njne	.myL86\n.myL131:\nmovq	%rdi, %rax\nandq	$-16, %rax\naddq	%rax, %rdx\ncmpq	%rax, %rdi\nje	.myL139\nvzeroupper\n.myL85:\nsubq	%rax, %rdi\nleaq	-1(%rdi), %rcx\ncmpq	$6, %rcx\njbe	.myL90\nvmovd	%r9d, %xmm3\nvpxor	%xmm5, %xmm5, %xmm5\nvmovd	%r10d, %xmm2\naddq	%r14, %rax\nleaq	(%rsi,%rax,2), %rcx\nvpbroadcastw	%xmm3, %xmm3\nvmovdqu	(%rbx,%rax,2), %xmm4\nmovq	%rdi, %rax\nvmovdqu	(%rcx), %xmm0\nvpbroadcastw	%xmm2, %xmm2\nvmovd	%r11d, %xmm1\nandq	$-8, %rax\nvpbroadcastw	%xmm1, %xmm1\naddq	%rax, %rdx\nvpsubusw	%xmm3, %xmm0, %xmm3\nvpxor	%xmm4, %xmm0, %xmm6\nvpcmpeqw	%xmm5, %xmm3, %xmm3\nvpblendvb	%xmm3, %xmm6, %xmm0, %xmm0\nvpsubusw	%xmm2, %xmm0, %xmm2\nvpxor	%xmm0, %xmm4, %xmm3\nvpcmpeqw	%xmm5, %xmm2, %xmm2\nvpblendvb	%xmm2, %xmm3, %xmm0, %xmm0\nvpsubusw	%xmm1, %xmm0, %xmm1\nvpxor	%xmm0, %xmm4, %xmm4\nvpcmpeqw	%xmm5, %xmm1, %xmm1\nvpblendvb	%xmm1, %xmm4, %xmm0, %xmm0\nvmovdqu	%xmm0, (%rcx)\ncmpq	%rax, %rdi\nje	.myL133\n.myL90:\nmovzwl	(%rsi,%rdx,2), %eax\nmovzwl	(%rbx,%rdx,2), %ecx\nleaq	1(%rdx), %rdi\nxorl	%eax, %ecx\ncmpw	%r9w, %ax\ncmovbe	%ecx, %eax\nmovzwl	(%rbx,%rdx,2), %ecx\nxorl	%eax, %ecx\ncmpw	%r10w, %ax\ncmovbe	%ecx, %eax\nmovzwl	(%rbx,%rdx,2), %ecx\nxorl	%eax, %ecx\ncmpw	%r11w, %ax\ncmovbe	%ecx, %eax\nmovw	%ax, (%rsi,%rdx,2)\ncmpq	%rdi, %r8\njle	.myL133\nmovzwl	(%rsi,%rdi,2), %eax\nmovzwl	(%rbx,%rdi,2), %ecx\nxorl	%eax, %ecx\ncmpw	%r9w, %ax\ncmovbe	%ecx, %eax\nmovzwl	(%rbx,%rdi,2), %ecx\nxorl	%eax, %ecx\ncmpw	%r10w, %ax\ncmovbe	%ecx, %eax\nmovzwl	(%rbx,%rdi,2), %ecx\nxorl	%eax, %ecx\ncmpw	%r11w, %ax\ncmovbe	%ecx, %eax\nmovw	%ax, (%rsi,%rdi,2)\nleaq	2(%rdx), %rdi\ncmpq	%rdi, %r8\njle	.myL133\nmovzwl	(%rsi,%rdi,2), %eax\nmovzwl	(%rbx,%rdi,2), %ecx\nxorl	%eax, %ecx\ncmpw	%r9w, %ax\ncmovbe	%ecx, %eax\nmovzwl	(%rbx,%rdi,2), %ecx\nxorl	%eax, %ecx\ncmpw	%r10w, %ax\ncmovbe	%ecx, %eax\nmovzwl	(%rbx,%rdi,2), %ecx\nxorl	%eax, %ecx\ncmpw	%r11w, %ax\ncmovbe	%ecx, %eax\nmovw	%ax, (%rsi,%rdi,2)\nleaq	3(%rdx), %rdi\ncmpq	%rdi, %r8\njle	.myL133\nmovzwl	(%rsi,%rdi,2), %eax\nmovzwl	(%rbx,%rdi,2), %ecx\nxorl	%eax, %ecx\ncmpw	%r9w, %ax\ncmovbe	%ecx, %eax\nmovzwl	(%rbx,%rdi,2), %ecx\nxorl	%eax, %ecx\ncmpw	%r10w, %ax\ncmovbe	%ecx, %eax\nmovzwl	(%rbx,%rdi,2), %ecx\nxorl	%eax, %ecx\ncmpw	%r11w, %ax\ncmovbe	%ecx, %eax\nmovw	%ax, (%rsi,%rdi,2)\nleaq	4(%rdx), %rdi\ncmpq	%rdi, %r8\njle	.myL133\nmovzwl	(%rsi,%rdi,2), %eax\nmovzwl	(%rbx,%rdi,2), %ecx\nxorl	%eax, %ecx\ncmpw	%r9w, %ax\ncmovbe	%ecx, %eax\nmovzwl	(%rbx,%rdi,2), %ecx\nxorl	%eax, %ecx\ncmpw	%r10w, %ax\ncmovbe	%ecx, %eax\nmovzwl	(%rbx,%rdi,2), %ecx\nxorl	%eax, %ecx\ncmpw	%r11w, %ax\ncmovbe	%ecx, %eax\nmovw	%ax, (%rsi,%rdi,2)\nleaq	5(%rdx), %rdi\ncmpq	%rdi, %r8\njle	.myL133\nmovzwl	(%rsi,%rdi,2), %eax\nmovzwl	(%rbx,%rdi,2), %ecx\nxorl	%eax, %ecx\ncmpw	%r9w, %ax\ncmovbe	%ecx, %eax\nmovzwl	(%rbx,%rdi,2), %ecx\nxorl	%eax, %ecx\ncmpw	%r10w, %ax\ncmovbe	%ecx, %eax\nmovzwl	(%rbx,%rdi,2), %ecx\nxorl	%eax, %ecx\ncmpw	%r11w, %ax\ncmovbe	%ecx, %eax\naddq	$6, %rdx\nmovw	%ax, (%rsi,%rdi,2)\ncmpq	%rdx, %r8\njle	.myL133\nmovzwl	(%rsi,%rdx,2), %eax\nmovzwl	(%rbx,%rdx,2), %ecx\nmovl	%eax, %edi\nxorl	%ecx, %edi\ncmpw	%r9w, %ax\ncmovbe	%edi, %eax\nmovl	%eax, %edi\nxorl	%ecx, %edi\ncmpw	%r10w, %ax\ncmovbe	%edi, %eax\nxorl	%eax, %ecx\ncmpw	%r11w, %ax\ncmovbe	%ecx, %eax\nmovw	%ax, (%rsi,%rdx,2)\n.myL133:\npopq	%rbx\npopq	%r12\npopq	%r13\npopq	%r14\npopq	%r15\npopq	%rbp\n.cfi_def_cfa 7, 8\nret\n.p2align 4,,10\n.p2align 3\n.myL135:\n.cfi_restore 3\n.cfi_restore 6\n.cfi_restore 12\n.cfi_restore 13\n.cfi_restore 14\n.cfi_restore 15\nret\n.myL114:\n.cfi_def_cfa 6, 16\n.cfi_offset 3, -56\n.cfi_offset 6, -16\n.cfi_offset 12, -48\n.cfi_offset 13, -40\n.cfi_offset 14, -32\n.cfi_offset 15, -24\nxorl	%eax, %eax\nleaq	sa(%rip), %rsi\nleaq	sb(%rip), %rbx\njmp	.myL85\n.myL139:\nvzeroupper\njmp	.myL133\n.cfi_endproc\n.myLFE9897:\n.size	_Z2uptttii, .-_Z2uptttii\n");

int main()
{
	cin.tie(0) -> sync_with_stdio(false);
	int k;
	cin >> n >> k;
	Loop (i,0,n)
		cin >> a[i] >> b[i];
	Loop (i,0,k)
		cin >> q[i];
	ll ans = 0;
	for (int l0 = 0; l0 < n; l0 += S0) {
		int r0 = min(n, l0+S0);
		vector<int> vec = {0};
		Loop (i,l0,r0) {
			vec.push_back(a[i]);
			vec.push_back(b[i]);
		}
		sort(vec.begin(), vec.end());
		vec.resize(unique(vec.begin(), vec.end()) - vec.begin());
		Loop (i,l0,r0) {
			sa[i] = lower_bound(vec.begin(), vec.end(), a[i]) - vec.begin();
			sb[i] = lower_bound(vec.begin(), vec.end(), b[i]) - vec.begin();
			sb[i] ^= sa[i];
		}
		Loop (i,0,k)
			sq[i] = upper_bound(vec.begin(), vec.end(), q[i]) - vec.begin() - 1;
		for (int l1 = l0; l1 < r0; l1 += S1) {
			int r1 = min(r0, l1+S1);
			for (int i = 0; i < k; i += 3)
				up(sq[i+0], sq[i+1], sq[i+2], l1, r1);
		}
		Loop (i,l0,r0)
			ans += vec[sa[i]];
	}
	cout << ans << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 304 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 2 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 340 KB Output is correct
11 Correct 2 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 1 ms 384 KB Output is correct
2 Correct 1 ms 304 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 2 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 340 KB Output is correct
11 Correct 2 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 724 KB Output is correct
15 Correct 40 ms 912 KB Output is correct
16 Correct 83 ms 1228 KB Output is correct
17 Correct 140 ms 1312 KB Output is correct
18 Correct 148 ms 1344 KB Output is correct
19 Correct 153 ms 1296 KB Output is correct
20 Correct 139 ms 1368 KB Output is correct
21 Correct 134 ms 1340 KB Output is correct
22 Correct 138 ms 1368 KB Output is correct
23 Correct 128 ms 1340 KB Output is correct
24 Correct 124 ms 1368 KB Output is correct
25 Correct 123 ms 1344 KB Output is correct
26 Correct 113 ms 1356 KB Output is correct
27 Correct 134 ms 1340 KB Output is correct
28 Correct 138 ms 1368 KB Output is correct
29 Correct 133 ms 1364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 304 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 2 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 340 KB Output is correct
11 Correct 2 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 724 KB Output is correct
15 Correct 40 ms 912 KB Output is correct
16 Correct 83 ms 1228 KB Output is correct
17 Correct 140 ms 1312 KB Output is correct
18 Correct 148 ms 1344 KB Output is correct
19 Correct 153 ms 1296 KB Output is correct
20 Correct 139 ms 1368 KB Output is correct
21 Correct 134 ms 1340 KB Output is correct
22 Correct 138 ms 1368 KB Output is correct
23 Correct 128 ms 1340 KB Output is correct
24 Correct 124 ms 1368 KB Output is correct
25 Correct 123 ms 1344 KB Output is correct
26 Correct 113 ms 1356 KB Output is correct
27 Correct 134 ms 1340 KB Output is correct
28 Correct 138 ms 1368 KB Output is correct
29 Correct 133 ms 1364 KB Output is correct
30 Correct 180 ms 1768 KB Output is correct
31 Correct 756 ms 2476 KB Output is correct
32 Correct 1462 ms 3052 KB Output is correct
33 Correct 2992 ms 4340 KB Output is correct
34 Correct 19 ms 1484 KB Output is correct
35 Correct 2937 ms 4336 KB Output is correct
36 Correct 2968 ms 4216 KB Output is correct
37 Execution timed out 3051 ms 4208 KB Time limit exceeded
38 Halted 0 ms 0 KB -