QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#630626 | #9249. Elimination Series Once More | 11d10xy | WA | 2ms | 10200kb | C++14 | 942b | 2024-10-11 19:36:37 | 2024-10-11 19:36:44 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int n,lgn,k,p[1<<20],invp[1<<20];
array<int,20>ls[1<<20],gr[1<<20];
void solve(int l,int r,int h){
if(l==r)return;
int mid=l+r>>1;
solve(l,mid,h-1),solve(mid+1,r,h-1);
vector<int>a(p+l,p+mid+1),b(p+mid+1,p+r+1);
for(int i=l,x=0,y=0;i<=r;i++){
if(y==b.size()||(x<a.size()&&a[x]<b[y])){
int u=invp[a[x]];
ls[u][h]=y,gr[u][h]=b.size()-y;
p[i]=a[x],x++;
}else{
int u=invp[b[y]];
ls[u][h]=x,gr[u][h]=a.size()-x;
p[i]=b[y],y++;
}
}
}
int main(){
scanf("%d%d",&lgn,&k),n=1<<lgn;
for(int i=0;i<n;i++){
scanf("%d",&p[i]),p[i]--,invp[p[i]]=i;
}
solve(0,n-1,lgn);
for(int i=0;i<n;i++){
int s=0,t=0;
for(int x:ls[i])s+=x;
while(t<lgn){
s-=ls[i][t+1],s-=gr[i][t+1];
if(s<0)break;t++;
}printf("%d ",t);
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 9936kb
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: 2ms
memory: 9944kb
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: 10200kb
input:
3 0 1 2 7 4 5 8 3 6
output:
0 1 2 2 2 3 1 2
result:
wrong answer 4th numbers differ - expected: '0', found: '2'