#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include class Set { private: std::vector set; public: Set() = default; explicit Set(const std::vector& v) { for (const auto &item: v) { this->Add(item); } } std::vector Data() const { return this->set; } void Add(int64_t num) { if (!this->Contains(num)) { this->set.push_back(num); } } void Remove(int64_t num) { this->set.erase(find(this->set.begin(), this->set.end(), num)); } bool Contains(int64_t num) const { return find(this->set.begin(), this->set.end(), num) != this->set.end(); } Set Union(const Set& other) const { Set s; for (const auto &item: this->Data()) { s.Add(item); } for (const auto &item: other.Data()) { s.Add(item); } return s; } Set Intersection(const Set& other) const { Set s; for (const auto &item: other.Data()) { if (this->Contains(item)) { s.Add(item); } } return s; } Set Difference(const Set& other) const { Set s; for (const auto &item: this->Data()) { if (!other.Contains(item)) { s.Add(item); } } return s; } Set SymmetricDifference(const Set& other) const { Set s; s = this->Difference(other); s = s.Union(other.Difference(*this)); return s; } };