QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#665945#8781. Element-Wise Comparisonucup-team134WA 4ms4464kbC++171.1kb2024-10-22 15:58:542024-10-22 15:58:54

Judging History

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

  • [2024-10-22 15:58:54]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:4464kb
  • [2024-10-22 15:58:54]
  • 提交

answer

#include <bits/stdc++.h>

#define ll long long
#define pb push_back
#define f first
#define s second
#define sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ld long double
#define li __int128

using namespace std;

mt19937 rng(time(NULL));

const int N=5;
int main()
{
	// 9:47
	// 9:57 done coding, but not correct
	ios;
	int n,m;
	cin >> n >> m;
	vector<int> ord(n);
	bitset<N> on;
	vector<bitset<N>> my(n),pr(n),sf(n);
	for(int i=0;i<n;i++){
		int x;
		cin >> x;
		ord[x-1]=i;
	}
	for(int i=n-1;i>=0;i--){
		my[ord[i]]=on>>ord[i];
		on[ord[i]]=1;
	}
	for(int i=0;i<n;i++){
		if(i%m==0){
			pr[i]=my[i];
		}
		else{
			pr[i]=pr[i-1]&my[i];
		}
	}
	for(int i=n-1;i>=0;i--){
		if(i==n-1||((i-1)%m==0)){
			sf[i]=my[i];
		}
		else{
			sf[i]=sf[i+1]&my[i];
		}
	}
	ll ans=0;
	int c=1;
	for(int i=0;i<=n-m;i++){
		c--;
		if(c==0){
			ans+=sf[i].count();
			c=m;
			continue;
		}
		ans+=(sf[i]&pr[i+m-1]).count();
	}
	printf("%lld\n",ans);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

5 3
5 2 1 3 4

output:

0

result:

ok answer is '0'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3796kb

input:

5 2
3 1 4 2 5

output:

2

result:

ok answer is '2'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3860kb

input:

4 2
1 2 3 4

output:

3

result:

ok answer is '3'

Test #4:

score: 0
Accepted
time: 0ms
memory: 3860kb

input:

4 2
4 3 2 1

output:

0

result:

ok answer is '0'

Test #5:

score: 0
Accepted
time: 0ms
memory: 3888kb

input:

1 1
1

output:

0

result:

ok answer is '0'

Test #6:

score: -100
Wrong Answer
time: 4ms
memory: 4464kb

input:

50000 2
44045 29783 5389 7756 44022 45140 21967 5478 10868 49226 21775 31669 49836 13511 46116 14229 27206 31168 37389 3158 10658 41154 14635 18526 40540 6451 23197 46719 30593 13517 8604 46666 39189 43746 12778 3684 3194 36979 43020 14652 19549 31178 17144 27177 44336 2849 40220 11751 41993 32209 4...

output:

20

result:

wrong answer expected '310780127', found '20'