QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#578464#8781. Element-Wise ComparisongzyWA 1ms5920kbC++14752b2024-09-20 19:21:522024-09-20 19:21:52

Judging History

你现在查看的是最新测评结果

  • [2024-09-20 19:21:52]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5920kb
  • [2024-09-20 19:21:52]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
using ll = long long;

const int N = 5e4 + 7;
int i, j, k, n, m, l, r;
int a[N], p[N], tr;
bitset<N> u[N], t[N], w, s, v;
ll res;

void build(int l, int r) {
	t[r] = u[a[r]]; tr = r; w.set();
	for(i = r - 1; i >= l; i--) t[i] = (t[i + 1] >> 1) & u[a[i]];
}

int main() {
	scanf("%d %d", &n, &m);
	for(i = 1; i <= n; i++) scanf("%d", &a[i]), p[a[i]] = i;
	for(i = 1; i < n; i++) u[i + 1] = u[i], u[i + 1][p[i]] = 1;
	l = 1, r = m; build(l, r);
	while(r < n) {
		++l, ++r;
		if(l > tr) {
			build(l, r);
			s = t[l];
		} else {
			w = w & (u[a[r]] >> r - tr);
			s = t[l] & (w >> tr - l);
		}
		s &= v;
		v[l] = 1;
		res += s.count();
	}
	printf("%lld\n", res);
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3864kb

input:

5 3
5 2 1 3 4

output:

0

result:

ok answer is '0'

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 5920kb

input:

5 2
3 1 4 2 5

output:

1

result:

wrong answer expected '2', found '1'