QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#628705 | #9249. Elimination Series Once More | cabbagea | WA | 3ms | 15896kb | C++17 | 1.4kb | 2024-10-10 21:47:46 | 2024-10-10 21:48:37 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N=1e6+10;
#define endl '\n';
typedef pair<int,int> pii;
int a[N];
int n,m;
int tr[N*2];
pii p[N*2][21];
int lowbit(int x){
return x&(-x);
}
void add(int index){
for(int i=index;i<N*2;i+=lowbit(i)) tr[i]++;
}
int getsum(int index){
int res=0;
for(int i=index;i;i-=lowbit(i)) res+=tr[i];
return res;
}
pii v[N*2];
void solve(){
cin>>n>>m;
for(int i=1;i<=n;i++)
{
int temp=1<<i;
for(int l=1;l<=(1<<n);l+=temp)
{
int r=l+temp-1;
for(int k=l;k<=r;k++)
p[k][i]={l,r};
}
}
int t=n;
n=1<<n;
for(int i=1;i<=n;i++)
{
cin>>v[i].first;
v[i].second=i;
}
sort(v+1,v+1+n);
vector<int> res(n+10);
for(int i=1;i<=n;i++)
{
auto [x,y]=v[i];
for(int k=1;k<=t;k++)
{
auto [l,r]=p[y][k];
int len=r-l+1;
if(i<len) break;
int temp=getsum(r)-getsum(l-1)+k;
if(temp>=len-1) res[y]++;
else break;
}
add(i);
}
for(int i=1;i<=n;i++) cout<<res[i]<<' ';
cout<<endl;
return ;
}
signed main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int T=1;
//cin>>T;
while(T--)
{
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 15832kb
input:
2 1 1 2 3 4
output:
0 1 1 2
result:
ok 4 number(s): "0 1 1 2"
Test #2:
score: 0
Accepted
time: 3ms
memory: 15892kb
input:
3 5 2 4 7 5 3 8 6 1
output:
1 2 2 2 1 3 2 0
result:
ok 8 numbers
Test #3:
score: -100
Wrong Answer
time: 2ms
memory: 15896kb
input:
3 0 1 2 7 4 5 8 3 6
output:
0 1 2 2 1 3 1 2
result:
wrong answer 4th numbers differ - expected: '0', found: '2'