#include <cstdio>
#include <queue>
using namespace std
;
struct mouse
{
int wei
;
int r
;
}mo
[1010];
queue
<int> qu
;
int main()
{
int np
,ng
,order
;
scanf("%d%d",&np
,&ng
);
for(int i
=0;i
<np
;i
++)
scanf("%d",&mo
[i
].wei
);
for(int i
=0;i
<np
;i
++)
{
scanf("%d",&order
);
qu
.push(order
);
}
int temp
=np
,group
;
while(qu
.size()!=1)
{
if(temp
%ng
==0)
group
=temp
/ng
;
else
group
=temp
/ng
+1;
for(int i
=0;i
<group
;i
++)
{
int k
=qu
.front();
for(int j
=0;j
<ng
;j
++)
{
if(i
*ng
+j
>=temp
)
break;
int front
=qu
.front();
if(mo
[front
].wei
>mo
[k
].wei
)
k
=front
;
mo
[front
].r
=group
+1;
qu
.pop();
}
qu
.push(k
);
}
temp
=group
;
}
mo
[qu
.front()].r
=1;
for(int i
=0;i
<np
;i
++)
{
printf("%d",mo
[i
].r
);
if(i
<np
-1)
printf(" ");
}
return 0;
}
转载请注明原文地址: https://mac.8miu.com/read-498578.html