Initial commit
This commit is contained in:
53
2022/city/12/grupuri/grupuri.cpp
Normal file
53
2022/city/12/grupuri/grupuri.cpp
Normal file
@@ -0,0 +1,53 @@
|
||||
#include <fstream>
|
||||
#include <set>
|
||||
#include <unordered_set>
|
||||
#include <unordered_map>
|
||||
using namespace std;
|
||||
|
||||
ifstream input_stream;
|
||||
ofstream output_stream;
|
||||
|
||||
|
||||
// Hashing function?
|
||||
string getGroupName(set<int16_t> group) {
|
||||
string res = "";
|
||||
for (auto it = group.begin(); it != group.end(); it++) {
|
||||
res += '0' + *it;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
int main() {
|
||||
input_stream.open("grupuri.in");
|
||||
output_stream.open("grupuri.out");
|
||||
|
||||
int N;
|
||||
input_stream >> N;
|
||||
|
||||
unordered_map<string, set<int16_t>> access;
|
||||
|
||||
for (int16_t i = 0; i < N; i++) {
|
||||
int m;
|
||||
input_stream >> m;
|
||||
|
||||
for (int j = 0; j < m; j++) {
|
||||
string code;
|
||||
input_stream >> code;
|
||||
|
||||
access[code].insert(i);
|
||||
}
|
||||
}
|
||||
|
||||
unordered_set<string> groups;
|
||||
|
||||
for (auto it = access.begin(); it != access.end(); it++) {
|
||||
groups.insert(getGroupName(it -> second));
|
||||
}
|
||||
|
||||
output_stream << groups.size() << endl;
|
||||
|
||||
input_stream.close();
|
||||
output_stream.close();
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user