sicily 1775. Simple Sort

#include<iostream>            
#include
<stdio.h>
#include
<algorithm>
using namespace std;
int n,m;
struct Priority
{
int id,p;
bool operator<(const Priority& other)const
{
return p<other.p;
}
}col[
12];
struct Node
{
int id,x[12];
bool operator<(const Node& other)const
{
for(int i=1;i<=m;++i)
if(x[col[i].id]<other.x[col[i].id])
return true;
else if(x[col[i].id]>other.x[col[i].id])
return false;
return id<other.id; //这句不可缺省
}
}node[
200];
int main()
{
int cases,q;
cin
>>cases;
while(cases--)
{
cin
>>n>>m;
for(int i=1;i<=n;++i)
{
node[i].id
=i;
for(int j=1;j<=m;++j)
cin
>>node[i].x[j];
}
cin
>>q;
while(q--)
{
for(int i=1;i<=m;++i)
{
col[i].id
=i;
cin
>>col[i].p;
}
sort(col
+1,col+m+1);
sort(node
+1,node+n+1);
for(int i=1;i<n;++i)
printf(
"%d ",node[i].id-1);
printf(
"%d\n",node[n].id-1);
}
}
return 0;
}

  

posted on 2011-07-23 10:48  sysu_mjc  阅读(474)  评论(0编辑  收藏  举报

导航