o,no:array[1..1000]of longint;
f:array[1..1000]of int64;
n,i,j,k,m:longint;
procedure qsort;
procedure sort(l,r:longint);
var i,j,x,y,t,c:longint;
begin
i:=l;
j:=r;
x:=o[(l+r)div 2];
t:=no[(l+r)div 2];
c:=f[(l+r)div 2];
repeat
while(o[i]>x)or((o[i]=x)and(f[i]<c))or((o[i]=x)and(f[i]=c)and(no[i]<t)) do inc(i);
while(o[j]<x)or((o[j]=x)and(f[j]>c))or((o[j]=x)and(f[j]=c)and(no[j]>t)) do dec(j);
if not(i>j)then
begin
y:=o[i];
o[i]:=o[j];
o[j]:=y;
y:=f[i];
f[i]:=f[j];
f[j]:=y;
y:=no[i];
no[i]:=no[j];
no[j]:=y;
inc(i);
dec(j);
end;
until i>j;
if l<j then sort(l,j);
if i<r then sort(i,r);
end;
begin
sort(1,n);
end;
begin
readln(n,m,k);
for i:=1 to n do
for j:=1 to k do
begin
readln(a[i,j]);
no[i]:=i;
end;
for i:=1 to n do
begin
for j:=1 to k do
o[i]:=o[i]+a[i,j];
o[i]:=trunc(o[i]/k);
end;
for i:=1 to n do
begin
for j:=1 to k do
f[i]:=f[i]+sqr(a[i,j]-o[i]);
f[i]:=trunc(f[i]/k);
end;
qsort;
for i:=1 to m-1 do
write(no[i],’ ’);
write(no[m]);
end.
测试结果1: 通过本测试点|有效耗时172:ms
测试结果2: 通过本测试点|有效耗时47:ms
测试结果3: 通过本测试点|有效耗时63:ms
测试结果4: 测试结果错误.错误结果为:45 48 30 43 50 66 65 29 2 37 68 18 46 32 23 15 27 8 10 19 60 44 14 26 38 28 55 16 24 12 52 53 9 11 35 34 57 56 36 51 63 33 67 54 41
正确结果应为:503 431 15 293 328 607 57 170 37 502 40 296 301 94 146 493 251 164 2 13 137 285 304 235 176 568 108 326 475 250 121 153 327 177 131 242 449 228 495 437 261 156 473 407 69
测试结果5: 测试结果错误.错误结果为:81 69 19 65 110 113 101 61 51 117 52 74 43 93 17 91 102 68 90 88 26 25 71 36 73 129 67 79 12 48 94 114 59
正确结果应为:503 251 600 134 84 593 273 69 192 562 585 208 474 269 33 56 479 258 115 515 518 119 501 569 306 623 612 555 207 205 369 496 92
测试结果6: 测试结果错误.错误结果为:16 118 228 110 180 159 182
正确结果应为:484 129 146 209 763 50 452
测试结果7: 通过本测试点|有效耗时157:ms
测试结果8: 测试结果错误.错误结果为:97 77 2 11 26 34 29 40 61 15 81 47 98
正确结果应为:293 414 870 751 335 861 776 33 860 661 392 68 572
测试结果9: 测试结果错误.错误结果为:43 122 74 56 111 52 85 7 33 128 77 87 31 78 76 90 137 116 4 60 99 83 15 109 127 139 88 17 136 28 62 50 26 101 132 70 130
正确结果应为:209 241 657 74 259 30 528 677 99 280 611 367 623 487 574 51 682 319 5 471 332 392 552 426 189 214 82 121 639 142 293 507 300 599 6 43 381
测试结果10: 测试结果错误.错误结果为:12 28 2 6 25 18 40 11 43 14 45 8 21 9 26 39 38 27 16 24 5 47 41 36 46 29 1 3 17 13 20 30 37 34 49 4 22 7 19 48 10 23 44 15 33 32 31 35 42 50 51
正确结果应为:237 158 279 21 250 169 312 192 144 8 238 318 120 78 248 84 137 55 3 154 297 145 95 190 261 32 313 76 198 299 139 65 164 173 126 244 149 225 26 12 71 272 92 232 161 45 306 5 234 295 296
var n,m,i,j,t,k:longint;
a:array[0..1010,0..1010] of longint;
b,c,k1:array[0..1010] of longint;
procedure jiaohuan(n,m:longint);
var t:longint;
begin
t:=b[n]; b[n]:=b[m]; b[m]:=t;
t:=c[n]; c[n]:=c[m]; c[m]:=t;
t:=k1[n]; k1[n]:=k1[m]; k1[m]:=t;
end;
begin
read(n); read(m); read(k);
for i:=1 to n do
for j:=1 to k do read(a[i,j]);
for i:=1 to n do
begin
for j:=1 to k do b[i]:=b[i]+a[i,j];
b[i]:=b[i] div k;
end;
for i:=1 to n do
begin
for j:=1 to k do
c[i]:=c[i]+(a[i,j])*(a[i,j]);
c[i]:=c[i]-k*b[i]*b[i];
c[i]:=c[i] div k;
end;
for i:=1 to n do k1[i]:=i;
for i:=1 to n-1 do
for j:=1 to n-i do
begin
if b[j]<b[j+1] then jiaohuan(j,j+1);
if b[j]=b[j+1] then
begin
if c[j]>c[j+1] then jiaohuan(j,j+1);
if c[j]=c[j+1] then
if k1[j]>k1[j+1] then jiaohuan(j,j+1);
end;
end;
for i:=1 to m-1 do write(k1[i],’ ’);
write(k1[m]);
end.
/* Accepted Code */
#include <stdio.h>
typedef struct Student
{
int ag,dit,nu;
};
Student st[1001]={0};
int n,m,k,ss=0,ob;
bool Compare(Student a,Student b)
{
if(a.ag<b.ag) return true; else
if(a.ag>b.ag) return false;
if(a.dit>b.dit) return true; else
if(a.dit<b.dit) return false;
if(a.nu>b.nu) return true; else
if(a.nu<b.nu) return false;
return false;
}
void Qsort(Student *a,int x,int y)
{
if(x>=y) return;
int p=x,q=y;
Student F=a[p];
while(p<q)
{
while(p<q&&Compare(a[q],F))
q--;
if(p<q)
a[p++]=a[q];
while(p<q&&!Compare(a[p],F))
p++;
if(p<q)
a[q--]=a[p];
}
a[p]=F;
Qsort(a,x,p-1);
Qsort(a,p+1,y);
}
int main()
{
int s;
scanf("%d %d %d",&n,&m,&k);
for(int i=0;i<n;i++)
{
s=0;
ss=0;
for(int j=0;j<k;j++)
{
scanf("%d",&ob);
s+=ob;
ss+=ob*ob;
}
st[i].nu=i+1;
st[i].ag=s/k;
st[i].dit=(ss-k*st[i].ag*st[i].ag)/k;
}
Qsort(st,0,n-1);
for(int i=0;i<m;i++)
{
if(i) printf(" ");
printf("%d",st[i].nu);
}
return 0;
}
var
begin
readln(n,m,k);
for i:=1 to n do
begin
b[i]:=i;
for j:=1 to k do
read(a[i,j]);
readln;
end;
qsort(1,n);{快排a,b,两个数组}
work(1,m+10);{前m个在按照成绩重复来排下}{多判断些重复没坏处}
for i:=1 to m do
write(b[i],' ');
writeln;
end.