此题要求前k小答案,我们首先把k个inf加入小根堆

#include <iostream>#include
<algorithm>#include
<cstdio>#include
<cstring>#include
<cstdlib>#include
<cmath>#define
mp make_pair#define
pa pair<int,int>#define
M 500005#include
<queue>#define
inf 0x3f3f3f3f#define
fi first#define
se secondusing namespace std;priority_queue<pa> pq;int
q[10],ans[M];struct
node{ int
ma[10],mi[10],d[10],l,r;}t[M];int
root,n,m,k,now;void
read(int
&tmp){ tmp=0;
char ch=getchar(); int
fu=1;
for
(;ch<‘0‘||ch>‘9‘;ch=getchar())
if
(ch==‘-‘)
fu=-1;
for
(;ch>=‘0‘&&ch<=‘9‘;ch=getchar())
tmp=tmp*10+ch-‘0‘;
tmp*=fu;}bool
cmp(node a,node b){ return
a.d[now]<b.d[now];}void Update(int
x){
int
l=t[x].l,r=t[x].r;
for
(int
i=0;i<k;i++)
{ t[x].mi[i]=min(t[x].mi[i],min(t[l].mi[i],t[r].mi[i]));
t[x].ma[i]=max(t[x].ma[i],max(t[l].ma[i],t[r].ma[i]));
}}int
Build(int
l,int
r,int
d){ now=d; int
mid=(l+r)>>1;
nth_element(t+1+l,t+1+mid,t+1+r,cmp);
if
(mid!=l) t[mid].l=Build(l,mid-1,(d+1)%k);
else
t[mid].l=0;
if
(mid!=r) t[mid].r=Build(mid+1,r,(d+1)%k);
else
t[mid].r=0;
Update(mid); return
mid;}int
Sqr(int x){
return
x*x;}int
Dis(int
x){
int
ans=0;
for
(int
i=0;i<k;i++)
ans+=Sqr(t[x].d[i]-q[i]);
return
ans;}int
Get(int
x){
int
ans=0;
for
(int
i=0;i<k;i++)
{ if
(q[i]<t[x].mi[i])
ans+=Sqr(t[x].mi[i]-q[i]);
if
(q[i]>t[x].ma[i])
ans+=Sqr(q[i]-t[x].ma[i]);
} return
ans;}void Query(int
x){
if
(!x)
return;
int
d0=Dis(x),dl=Get(t[x].l),dr=Get(t[x].r);
if
(d0<pq.top().fi)
{ pq.pop();
pq.push(mp(d0,x));
} if
(dl<dr) { if
(dl<pq.top().fi) Query(t[x].l);
if
(dr<pq.top().fi) Query(t[x].r);
} else
{ if
(dr<pq.top().fi) Query(t[x].r);
if
(dl<pq.top().fi) Query(t[x].l);
}}int
main(){ while
(scanf("%d%d",&n,&k)!=EOF)
{ for
(int
j=0;j<k;j++)
t[0].ma[j]=-inf,t[0].mi[j]=inf;
for
(int
i=1;i<=n;i++)
for
(int
j=0;j<k;j++)
{ read(t[i].d[j]);
t[i].ma[j]=t[i].mi[j]=t[i].d[j];
} root=Build(1,n,0);
int
Q; read(Q);
while
(Q--) { for
(int
i=0;i<k;i++)
read(q[i]);
read(m);
printf("the
closest %d points are:\n",m);
for
(int
i=1;i<=m;i++)
pq.push(mp(inf,0));
Query(root); for
(int
i=1;i<=m;i++)
ans[i]=pq.top().se,pq.pop();
for
(int
i=m;i;i--)
{ for
(int
j=0;j<k;j++)
{ if
(j) printf("
");
printf("%d",t[ans[i]].d[j]);
} printf("\n");
} } } return
0;
}

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2478

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2479

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2480

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2481

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2482

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2483

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2484

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2485

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2486

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2487

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2488

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2489

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2490

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2491

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2492

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2493

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2494

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2495

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2496

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2497

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2498

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2499

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2500

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2501

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2502

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2503

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2504

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2505

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2506

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2507

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2508

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2509

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2510

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2511

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2512

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2513

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2514

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2515

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2516

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2517

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2518

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2519

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2520

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2521

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2522

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2523

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2524

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2525

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2526

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2527

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2528

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2529

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2530

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2531

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2532

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2533

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2534

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2535

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2536

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2537

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2538

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2539

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2540

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2541

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2542

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2543

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2544

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2545

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2546

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2547

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2548

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2549

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2550

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2551

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2552

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2553

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2554

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2555

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2556

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2557

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2558

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2559

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2560

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2561

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2562

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2563

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2564

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2565

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2566

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2567

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2568

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2569

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2570

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2571

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2572

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2573

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2574

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2575

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2576

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2577

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2578

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2579

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2580

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2581

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2582

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2583

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2584

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2585

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2586

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2587

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2588

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2589

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2590

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2591

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2592

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2593

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2594

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2595

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2596

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2597

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2598

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2599

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2600

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2601

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2602

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2603

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2604

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2605

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2606

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2607

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2608

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2609

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2610

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2611

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2612

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2613

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2614

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2615

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2616

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2617

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2618

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2619

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2620

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2621

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2622

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2623

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2624

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2625

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2626

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2627

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2628

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2629

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2630

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2631

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2632

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2633

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2634

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2635

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2636

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2637

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2638

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2639

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2640

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2641

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2642

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2643

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2644

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2645

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2646

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2647

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2648

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2649

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2650

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2651

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2652

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2653

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2654

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2655

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2656

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2657

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2658

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2659

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2660

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2661

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2662

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2663

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2664

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2665

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2666

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2667

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2668

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2669

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2670

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2671

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2672

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2673

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2674

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2675

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2677

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2678

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2679

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2680

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2681

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2682

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2683

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2684

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2685

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2686

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2687

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2688

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2689

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2690

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2691

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2692

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2693

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2694

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2695

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2696

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2697

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2698

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2699

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2700

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2701

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2702

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2703

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2704

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2705

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2706

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2707

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2708

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2709

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2710

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2711

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2712

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2713

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2714

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2715

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2716

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2717

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2718

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2719

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2720

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2721

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2722

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2723

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2724

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2725

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2726

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2727

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2728

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2729

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2730

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2731

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2732

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2733

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2734

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2735

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2736

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2737

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2738

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2739

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2740

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2741

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2742

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2743

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2744

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2745

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2746

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2747

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2748

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2749

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2750

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2751

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2752

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2753

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2754

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2755

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2756

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2757

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2758

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2759

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2760

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2761

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2762

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2763

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2764

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2765

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2766

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2767

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2768

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2769

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2770

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2771

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2772

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2773

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2774

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2775

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2776

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2777

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2778

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2779

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2780

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2781

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2782

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2783

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2784

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2785

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2786

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2787

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2788

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2789

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2790

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2791

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2792

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2793

http://u.xzw.com/index.php?app=public&mod=Profile&act=index&uid=2794

时间: 2024-08-09 06:32:27

此题要求前k小答案,我们首先把k个inf加入小根堆的相关文章

cogs930.[河南省队2012] 找第k小的数

930. [河南省队2012] 找第k小的数 ★★★   输入文件:kth.in   输出文件:kth.out   简单对比 时间限制:1 s   内存限制:128 MB 题目描述 看到很短的题目会让人心情愉悦,所以给出一个长度为N的序列A1,A2,A3,...,AN, 现在有M个询问,每个询问都是Ai...Aj中第k小的数等于多少. 输入格式 第一行两个正整数N,M.第二行N个数,表示序列A1,A2,...,AN.紧着的M行,每行三个正整数i,j,k(k≤j-i+1),表示 询问Ai...Aj

最快效率求出乱序数组中第k小的数

题目:以尽量高的效率求出一个乱序数组中按数值顺序的第k 的元素值 思路:这里很容易想到直接排序然后顺序查找,可以使用效率较高的快排,但是它的时间复杂度是O(nlgn),我们这里可以用一种简便的方法,不一定需要排序,使用快速排序中双向分区的扫描方法,扫描出主元下标,然后根据主元的值将数组划分成一半大,一半小.然后再根据主元下标与k进行比较,如果相等,说明主元就是我们要找的数,如果大于k,说明k所代表的值在小的那边,继续向小的那部分递归,如果小于k,说明k代表的值在大的那边,继续向大的那部分递归.这

第k小问题

例题1:[poj2104]K-th Number(区间第k小模板题) 题意:询问给定序列静态区间第k小 0.将区间第k小/大转化为存在k个数小于等于/大于等于它且最小/大的数(挺有用的) 1.可持久化线段树(主席树)/可持久化字典树,这里就不写了(在线) 2.分块,询问先二分答案,相当于求小于等于它的数个数,整块用暴力排序(初始)+二分/预处理(不用排序)来解决,散块暴力(在线) 1 #include<cstdio> 2 #include<cstring> 3 #include&l

COGS 930. [河南省队2012] 找第k小的数

题目描述 看到很短的题目会让人心情愉悦,所以给出一个长度为N的序列A1,A2,A3,...,AN, 现在有M个询问,每个询问都是Ai...Aj中第k小的数等于多少. 输入格式 第一行两个正整数N,M. 第二行N个数,表示序列A1,A2,...,AN. 紧着的M行,每行三个正整数i,j,k(k≤j-i+1),表示 询问Ai...Aj中第k小的数等于多少. 输出格式 共输出M行,第i行输出第i个询问的答案. 样例输入1: 4 3 4 1 2 3 1 3 1 2 4 3 1 4 4 样例输出1: 1

HDU 2665.Kth number 区间第K小

Kth number Time Limit: 15000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 11394    Accepted Submission(s): 3465 Problem Description Give you a sequence and ask you the kth big number of a inteval. Input The f

【2012河南省队互测】【COGS930】找第k小的数

题目描述 看到很短的题目会让人心情愉悦,所以给出一个长度为N的序列A1,A2,A3,-,AN, 现在有M个询问,每个询问都是Ai-Aj中第k小的数等于多少. 输入格式 第一行两个正整数N,M. 第二行N个数,表示序列A1,A2,-,AN. 紧着的M行,每行三个正整数i,j,k(k≤j-i+1),表示 询问Ai-Aj中第k小的数等于多少. 输出格式 共输出M行,第i行输出第i个询问的答案. 样例输入1: 4 3 4 1 2 3 1 3 1 2 4 3 1 4 4 样例输出1: 1 3 4 样例输入

[河南省队2012] 找第k小的数

★★☆   输入文件:kth.in   输出文件:kth.out   简单对比时间限制:1 s   内存限制:128 MB 题目描述 看到很短的题目会让人心情愉悦,所以给出一个长度为N的序列A1,A2,A3,...,AN, 现在有M个询问,每个询问都是Ai...Aj中第k小的数等于多少. 输入格式 第一行两个正整数N,M. 第二行N个数,表示序列A1,A2,...,AN. 紧着的M行,每行三个正整数i,j,k(k≤j-i+1),表示 询问Ai...Aj中第k小的数等于多少. 输出格式 共输出M行

Luogu P1923 求第k小的数

Luogu P1923 求第k小的数 一看这题,静态查询区间第$k$小的数,不就是可持久化线段树(主席树)的模板题吗?!(误) 直接把主席树的板子打上来?: #include<bits/stdc++.h> #define N 200010 #define mid ((l+r)>>1) using namespace std; int n,m,l,r,k,ans,id,siz; int a[N],b[N]; struct segmenttree { int ls,rs,sum,roo

二分——无序数组快速查找第K小的数

#1133 : 二分·二分查找之k小数 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 在上一回里我们知道Nettle在玩<艦これ>,Nettle的镇守府有很多船位,但船位再多也是有限的.Nettle通过捞船又出了一艘稀有的船,但是已有的N(1≤N≤1,000,000)个船位都已经有船了.所以Nettle不得不把其中一艘船拆掉来让位给新的船.Nettle思考了很久,决定随机选择一个k,然后拆掉稀有度第k小的船. 已知每一艘船都有自己的稀有度,Nettle现在把所有