QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#435821 | #8781. Element-Wise Comparison | Forever_Young# | WA | 130ms | 615052kb | C++23 | 948b | 2024-06-08 21:50:20 | 2024-06-08 21:50:22 |
Judging History
answer
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=1;i<=n;++i)
#define pb push_back
#define mp make_pair
using namespace std;
#define N 50010
bitset<N> a[N],b[N];
int n,m,p[N],pos[N];
int main()
{
cin>>n>>m;
rep(i,n)scanf("%d",&p[i]);
rep(i,n)pos[p[i]]=i;
bitset<N> x; x.reset();
for(int i=n;i>=1;i--)
{
a[pos[i]]=x>>pos[i];
x[pos[i]]=1;
}
long long ans=0;
x.set();
b[m]=a[m];
for(int i=m-1;i>=1;i--)b[i]=b[i+1]&a[i];
ans+=b[1].count();
int now=1;
for(int i=m+1;i<=n;i++)
{
x&=a[i];
if (now%m==0)
{
b[i]=a[i];
for(int j=i-1;j>=i-m+1;j--)b[j]=b[j+1]&a[j];
}
now++;
ans+=(x&b[now]).count();
}
cout<<ans<<endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5716kb
input:
5 3 5 2 1 3 4
output:
0
result:
ok answer is '0'
Test #2:
score: 0
Accepted
time: 1ms
memory: 5732kb
input:
5 2 3 1 4 2 5
output:
2
result:
ok answer is '2'
Test #3:
score: 0
Accepted
time: 1ms
memory: 5864kb
input:
4 2 1 2 3 4
output:
3
result:
ok answer is '3'
Test #4:
score: 0
Accepted
time: 1ms
memory: 5924kb
input:
4 2 4 3 2 1
output:
0
result:
ok answer is '0'
Test #5:
score: 0
Accepted
time: 1ms
memory: 7968kb
input:
1 1 1
output:
0
result:
ok answer is '0'
Test #6:
score: -100
Wrong Answer
time: 130ms
memory: 615052kb
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:
63789
result:
wrong answer expected '310780127', found '63789'