QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#441024#8781. Element-Wise Comparisonpengpeng_fudanWA 1ms7756kbC++23744b2024-06-14 10:18:142024-06-14 10:18:15

Judging History

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

  • [2024-06-14 10:18:15]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:7756kb
  • [2024-06-14 10:18:14]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using ull=unsigned long long;
using ll=long long;
const int S=50010;
bitset<50010> s1[S],s2[S],mp[S],p;
int ve[50010];
void solve() {
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		int num;cin>>num;
		ve[num]=i-1;
	}
	for(int i=n;i>=1;i--){
		mp[ve[i]]=(p>>ve[i]);
		p[i]=1;
	}
	for(int i=n-1;i>=0;i--){
		if(i%m==0)	s1[i]=mp[i];
		else s1[i]=(s1[i+1]&mp[i]);
	}
	for(int i=0;i<=n-1;i++){
		if(i%m==0)	s2[i]=mp[i];
		else s2[i]=(s2[i-1]&mp[i]);
	}
	ll ans=0;
	for(int i=0;i<n;i++){
		if(i+m-1<n) ans+=(s2[i]&s1[i+m-1]).count();
	}
	cout<<ans<<'\n';
}
int main() {
	ios::sync_with_stdio(0),cin.tie(0);
	int _ = 1;
	//cin >> _;
	while(_--) solve();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 5684kb

input:

5 3
5 2 1 3 4

output:

0

result:

ok answer is '0'

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 7756kb

input:

5 2
3 1 4 2 5

output:

0

result:

wrong answer expected '2', found '0'