It is said that in 2011, there are about 100 graduate schools ready to proceed over 40,000 applications in Zhejiang Province. It would help a lot if you could write a program to automate the admission procedure.

Each applicant will have to provide two grades: the national entrance exam grade

• The applicants are ranked according to their final grades, and will be admitted one by one from the top of the rank list.

• If there is a tied final grade, the applicants will be ranked according to their national entrance exam grade

• Each applicant may have

• If there is a tied rank, and if the corresponding applicants are applying to the same school, then that school must admit all the applicants with the same rank, even if its quota will be exceeded.

### Input Specification:

Each input file contains one test case.

Each case starts with a line containing three positive integers:

In the next line, separated by a space, there are

Then

### Output Specification:

For each test case you should output the admission results for all the graduate schools. The results of each school must occupy a line, which contains the applicants' numbers that school admits. The numbers must be in increasing order and be separated by a space. There must be no extra space at the end of each line. If no applicant is admitted by a school, you must output an empty line correspondingly.

### Sample Input:

11 6 3
2 1 2 2 2 3
100 100 0 1 2
60 60 2 3 5
100 90 0 3 4
90 100 1 2 0
90 90 5 1 3
80 90 1 0 2
80 80 0 1 2
80 80 0 1 2
80 70 1 3 2
70 80 1 2 3
100 100 0 2 4


### Sample Output:

0 10
3
5 6 7
2 8

1 4

————————————————

AC代码：

#include<bits/stdc++.h>
using namespace std;
int n,m,k;
struct node{
int id;
int rank;
int ge,gi;
vector<int>cho;
}a[40005];
int num[205];
int ran[205];
vector<int>sch[205];
bool cmp(node x,node y){
if((x.ge+x.gi)==(y.ge+y.gi)){
return x.ge>y.ge;
}else{
return (x.ge+x.gi)>(y.ge+y.gi);
}
}
bool cmp2(int x,int y){
return x<y;
}
int main(){
cin>>n>>m>>k;
memset(ran,0,sizeof(ran));
for(int i=0;i<m;i++) cin>>num[i];
for(int i=0;i<n;i++){
cin>>a[i].ge>>a[i].gi;
a[i].id=i;
for(int j=1;j<=k;j++){
int x;
cin>>x;
a[i].cho.push_back(x);
}
}
sort(a,a+n,cmp);
for(int i=0;i<n;i++){
if(i==0) a[i].rank=1;//计算排名
else{
if(a[i].ge==a[i-1].ge && a[i].gi==a[i-1].gi){
a[i].rank=a[i-1].rank;
}else{
a[i].rank=a[i-1].rank+1;
}
}
for(int j=0;j<k;j++){//开始分流志愿
int x=a[i].cho.at(j);
if(num[x]>0||ran[x]==a[i].rank){//排名相同也可
sch[x].push_back(a[i].id);
num[x]--;
if(num[x]==0) ran[x]=a[i].rank;
break;
}
}
}
for(int i=0;i<m;i++){
sort(sch[i].begin(),sch[i].end(),cmp2);//学校内部排序
if(sch[i].size()!=0){
for(int j=0;j<sch[i].size();j++){
cout<<sch[i].at(j);
if(j!=sch[i].size()-1) cout<<" ";
}
}
cout<<endl;
}
return 0;
}

©️2019 CSDN 皮肤主题: 像素格子 设计师: CSDN官方博客