-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwncc_22b1536.cpp
92 lines (78 loc) · 2.46 KB
/
wncc_22b1536.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#include <iostream>
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
bool f(unordered_map<string, vector<int>>& students, const string& project, const string& rollNumber) {
vector<int>& skills = students[rollNumber];
for (auto& student : students) {
if (student.first != rollNumber && student.second == skills) {
if (student.first == rollNumber)
return true;
}
}
return false;
}
int main() {
unordered_map<string, vector<int>> students;
unordered_set<string> jp;
int n, m;
cout << "Number of students: ";
cin >> n;
for (int i = 0; i < n; i++) {
string rn;
vector<int> sl(5);
cout << "Enter student's roll number followed by skill levels (HTML, Python, DSA, Java, SQL): ";
cin >> rn;
for (int j = 0; j < 5; j++) {
cin >> sl[j];
}
students[rn] = sl;
}
int cp = 0;
cout << "number of projects: ";
cin >> m;
for (int i = 0; i < m; i++) {
string projectName;
vector<int> a(5);
cout << "project name: ";
cin >> projectName;
cout << "required skill levels (HTML, Python, DSA, Java, SQL): ";
for (int j = 0; j < 5; j++) {
cin >> a[j];
}
bool projectCompleted = true;
for (int j = 0; j < 5; j++) {
int skillRequired = a[j];
if (skillRequired == 0) {
continue;
}
bool sk = false;
for (auto& student : students) {
string rollNumber = student.first;
if (jp.count(rollNumber) > 0)
continue;
if (student.second[j] >= skillRequired) {
sk = true;
jp.insert(rollNumber);
break;
} else if (student.second[j] == skillRequired - 1) {
if (f(students, projectName, rollNumber)) {
sk = true;
jp.insert(rollNumber);
break;
}
}
}
if (!sk) {
projectCompleted = false;
break;
}
}
if (projectCompleted) {
cp++;
}
}
cout << "Total completed projects: " << cp << endl;
return 0;
}