QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#594135#8781. Element-Wise ComparisonmaxiaomengTL 1ms5672kbC++14610b2024-09-27 19:36:362024-09-27 19:36:36

Judging History

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

  • [2024-09-27 19:36:36]
  • 评测
  • 测评结果:TL
  • 用时:1ms
  • 内存:5672kb
  • [2024-09-27 19:36:36]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
const int N=50005;
int n,m,a[N],r;
bitset<N> f[N],g[N],k;
signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
	cin>>n>>m;
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=1;i<=n;i++){
		for(int j=1;i+j<=n;j++){
			f[i][j]=(a[i]<a[i+j]);
		}
	}
	for(int i=m;i<=n;i+=m){
		k.set();
		for(int j=1;j<=m;j++){
			k&=f[i-j+1];
			g[i-j+1]=k;
		}
		k.set();
		for(int j=1;j<=m&&i+j-1<=n;j++){
			k&=f[i+j-1];
			r+=(k&g[i-(m-j+1)+1]).count();
		}
	}
	cout<<r;
    return 0;
}


Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

5 3
5 2 1 3 4

output:

0

result:

ok answer is '0'

Test #2:

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

input:

5 2
3 1 4 2 5

output:

2

result:

ok answer is '2'

Test #3:

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

input:

4 2
1 2 3 4

output:

3

result:

ok answer is '3'

Test #4:

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

input:

4 2
4 3 2 1

output:

0

result:

ok answer is '0'

Test #5:

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

input:

1 1
1

output:

0

result:

ok answer is '0'

Test #6:

score: -100
Time Limit Exceeded

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:


result: