-
Notifications
You must be signed in to change notification settings - Fork 0
/
1080.cpp
66 lines (66 loc) · 1.46 KB
/
1080.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <bits/stdc++.h>
using namespace std;
struct applicant{
int id;
double ge, gi, gf;
applicant(){id=ge=gi=gf=-1;}
applicant(int idd, double e, double i){
id = idd;
ge = e;
gi = i;
gf = (ge + gi) / 2;
}
friend bool operator==(const applicant &a, const applicant &b){
return (a.ge==b.ge && a.gi==b.gi);
}
};
bool cmp(const applicant &a, const applicant &b){
if(a.gf != b.gf) return a.gf > b.gf;
else if(a.ge != b.ge) return a.ge > b.ge;
else return a.id < b.id;
}
int n, m, k;
vector<set<int>> school;
vector<applicant> schBack;
vector<int> quota;
vector<applicant> apply;
vector<vector<int>> choice;
int main(){
ios::sync_with_stdio(false);
cin>>n>>m>>k;
apply.resize(n);
choice.resize(n, vector<int>(k));
school.resize(m);
schBack.resize(m);
quota.resize(m);
for(int i=0; i<m; i++){
cin>>quota[i];
}
for(int i=0; i<n; i++){
double ge, gi;
cin>>ge>>gi;
apply[i] = applicant(i, ge, gi);
for(int j=0; j<k; j++){
cin>>choice[i][j];
}
}
sort(apply.begin(), apply.end(), cmp);
for(int i=0; i<n; i++){
for(int j=0; j<k; j++){
int cho = choice[apply[i].id][j];//这里不要写成choice[i][j],因为choice和apply已经错位了
if(school[cho].size()<quota[cho] || schBack[cho]==apply[i]){
school[cho].insert(apply[i].id);
schBack[cho] = apply[i];
break;
}
}
}
for(int i=0; i<m; i++){
for(auto it=school[i].begin(); it!=school[i].end(); it++){
if(it != school[i].begin()) cout<<' ';
cout<<*it;
}
cout<<endl;
}
return 0;
}