Revisit 2022/city/12/grupuri

This commit is contained in:
2025-06-01 20:12:19 +03:00
parent 020825186a
commit 5ad12298fc
2 changed files with 110 additions and 0 deletions

View 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;
}