QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#577302 | #8781. Element-Wise Comparison | cyl001 | TL | 1ms | 5900kb | C++14 | 668b | 2024-09-20 10:12:02 | 2024-09-20 10:12:02 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 5e4 + 5;
int n,m,cnt,p[N],pos[N];
bitset <N> k[N],f[N];
int main()
{
scanf("%d%d",&n,&m);
for(int i = 1;i <= n;i++)
{
scanf("%d",&p[i]);
pos[p[i]] = i;
}
for(int i = 1;i <= n;i++) k[pos[i]] = k[pos[i - 1]],k[pos[i]][n - pos[i]] = 1;
for(int i = 1;i <= n;i++) k[i] >>= (n - i + 1),f[i] = k[i];
for(int j = 1;j <= 20;j++)
{
for(int i = n;i >= (1 << j);i--) f[i] &= f[i - (1 << (j - 1))];
if(m & (1 << j))
{
for(int i = m;i <= n;i++)
k[i] &= f[i - (m & ((1 << j) - 1))];
}
}
for(int i = m;i <= n;i++) cnt += k[i].count();
printf("%d\n",cnt);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3936kb
input:
5 3 5 2 1 3 4
output:
0
result:
ok answer is '0'
Test #2:
score: 0
Accepted
time: 1ms
memory: 3804kb
input:
5 2 3 1 4 2 5
output:
2
result:
ok answer is '2'
Test #3:
score: 0
Accepted
time: 1ms
memory: 4124kb
input:
4 2 1 2 3 4
output:
3
result:
ok answer is '3'
Test #4:
score: 0
Accepted
time: 1ms
memory: 5900kb
input:
4 2 4 3 2 1
output:
0
result:
ok answer is '0'
Test #5:
score: 0
Accepted
time: 1ms
memory: 3876kb
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...