QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#441024 | #8781. Element-Wise Comparison | pengpeng_fudan | WA | 1ms | 7756kb | C++23 | 744b | 2024-06-14 10:18:14 | 2024-06-14 10:18:15 |
Judging History
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'