Revisit 2022/city/12/grupuri
This commit is contained in:
53
2022/city/12/grupuri/grupuri_tests11-20.cpp
Normal file
53
2022/city/12/grupuri/grupuri_tests11-20.cpp
Normal file
@@ -0,0 +1,53 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
string inName = "test.in";
|
||||
string outName = "test.out";
|
||||
|
||||
if (argc > 1) {
|
||||
inName = argv[1];
|
||||
cout << "Using \"" << inName << "\" for test name" << endl;
|
||||
} else {
|
||||
cout << "Warning: no in name provided, defaulting to test.in" << endl;
|
||||
}
|
||||
|
||||
if (argc > 2) {
|
||||
outName = argv[2];
|
||||
cout << "Using \"" << outName << "\" for out name" << endl;
|
||||
} else {
|
||||
cout << "Warning: no out name proviced, defaulting to test.out" << endl;
|
||||
}
|
||||
|
||||
ifstream in(inName);
|
||||
ofstream out(outName);
|
||||
|
||||
// ***************** SOLUTION START HERE *****************
|
||||
|
||||
int n;
|
||||
in >> n;
|
||||
|
||||
unordered_map<int, bitset<100>> permissions;
|
||||
|
||||
|
||||
int canAccessCounter;
|
||||
int userID;
|
||||
for (int i = 0; i < n; i++) {
|
||||
in >> canAccessCounter;
|
||||
for (int j = 0; j < canAccessCounter; j++) {
|
||||
in >> userID;
|
||||
permissions[userID].set(i);
|
||||
}
|
||||
}
|
||||
|
||||
unordered_set<string> group_permissions;
|
||||
for (auto it = permissions.begin(); it != permissions.end(); it++) {
|
||||
group_permissions.insert((*it).second.to_string());
|
||||
}
|
||||
out << group_permissions.size() << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user