QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#594164 | #8781. Element-Wise Comparison | maxiaomeng | WA | 1ms | 5708kb | C++14 | 606b | 2024-09-27 19:50:16 | 2024-09-27 19:50:17 |
Judging History
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,l;
int z[N];
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],z[a[i]]=i;
for(int i=n;i;--i){
f[z[i]]=l<<z[i];
l.set(z[i]);
}
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;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 5648kb
input:
5 3 5 2 1 3 4
output:
0
result:
ok answer is '0'
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 5708kb
input:
5 2 3 1 4 2 5
output:
1
result:
wrong answer expected '2', found '1'