21 for(
int i = 0; i < N; i++) {
23 stu->
c_priority = unordered_map<Company *, int>();
24 stu->
priority_c = unordered_map<int, Company *>();
27 com->
priority = unordered_map<Student *, int>();
30 for(
int i = 0; i < N; i++) {
31 for(
int j = 0; j < N; j++) {
40 for(
int i = 0; i < N; i++) {
42 if(stu->matched_company ==
nullptr) {
44 stu->priority_c[stu->current_priority++]->proposed_students.insert(stu);
48 for(
int i = 0; i < N; i++) {
50 Student *current_matched_student = com->matched_student;
51 if(com->proposed_students.size() > 0) {
52 int min_priority = com->matched_student ? com->priority[com->matched_student] : INT_MAX;
53 Student *max_p_student = com->matched_student;
54 for(
auto stu: com->proposed_students) {
55 if(com->priority[stu] < min_priority) {
56 min_priority = com->priority[stu];
62 if(current_matched_student !=
nullptr) {
65 com->matched_student = max_p_student;
68 com->proposed_students.clear();
72 vector<int> ans = vector<int>(N, -1);
73 for(
int i = 0; i < N; i++) {
74 ans[i] =
students[i]->matched_company->id;