QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#460074 | #8781. Element-Wise Comparison | ucup-team2307# | WA | 1ms | 3580kb | C++20 | 1.6kb | 2024-06-30 21:13:02 | 2024-06-30 21:13:06 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
typedef long long ll;
//#define int ll
int n, m;
int p[50500];
int q[50500];
bitset<50500> bs[50500];
bitset<50500> b;
#define C 1000
main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>n>>m;
for (int i=1; i<=n; i++)
cin>>p[i], q[p[i]] = i;
for (int i=1; i<=n; i++)
b[i] = 1;
for (int i=1; i<=n; i++)
{
b[q[i]] = 0;
if (i%C == 0)
{
for (int d=1; d<=n-1; d++)
bs[d] |= (b & ((~b) >> d));
}
}
for (int i=1; i<=n; i++)
for (int j=i; ; j++)
{
if (i!=j)
if (q[j] < q[i])
bs[q[i]-q[j]][q[j]] = 1;
if (j%C == 0)
break;
}
for (int i=1; i+1<=n; i++)
bs[i] >>= 1;
// for (int i=1; i+1<=n; i++, cout<<"\n")
// for (int j=1; j<=n; j++)
// cout<<bs[i][j];
ll ans = 0;
for (int i=1; i+1<=n; i++)
{
int D = n-i-m+1;
// for (int j=0; j<D; j++)
// cout<<bs[i][j];
// cout<<"\n";
int mleft = m-1;
for (int j=1; mleft > 0; j*=2)
{
j = min(j, mleft);
bs[i] |= (bs[i] << j);
mleft -= j;
}
// for (int j=0; j<D; j++)
// cout<<bs[i][j];
// cout<<"\n";
int all = bs[i].count();
int lt = (bs[i]>>D).count();
int ones = all-lt;
int zeroes = D - ones;
ans += zeroes;
}
cout<<ans<<"\n";
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3580kb
input:
5 3 5 2 1 3 4
output:
-4
result:
wrong answer expected '0', found '-4'