QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#644094#8781. Element-Wise Comparisonliujunyi123WA 1ms5936kbC++14614b2024-10-16 10:52:282024-10-16 10:52:28

Judging History

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

  • [2024-10-16 10:52:28]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5936kb
  • [2024-10-16 10:52:28]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=50005;
int n,m,a[N],id[N];
long long ans;
bitset<N> b[N],s[N],tmp,sum,res;
bool cmp(int x,int y){return a[x]>a[y];}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]),id[i]=i;
	sort(id+1,id+n+1,cmp);
	for(int i=1;i<=n;i++){
		b[id[i]]=tmp>>id[i];
		tmp[id[i]]=1;
	}
	for(int i=m;i<=n;i+=m){
		int l=i-m+1,r=min(n,i+m);
		s[0]=sum=tmp;
		for(int j=i+1;j<=r;j++)s[j-i]=s[j-i-1]&b[j];
		for(int j=i;j>=l;j--){
			sum&=b[j];
			res=sum&s[j-i+1];
			ans+=res.count();
		}
	}
	printf("%lld\n",ans);
	return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 5936kb

input:

5 3
5 2 1 3 4

output:

2

result:

wrong answer expected '0', found '2'