fork download
  1. #include <iostream>
  2. #include <utility>
  3. #include <algorithm>
  4. #include <set>
  5. using namespace std;
  6.  
  7. using OP = pair<unsigned long long , unsigned long long>;
  8. using SOP = set<OP>;
  9.  
  10. template <class T>
  11. bool is_symetric (set<pair<T,T>> sop) {
  12. return all_of(sop.cbegin(), sop.cend(),
  13. [&sop](auto &x){ return x.first==x.second || sop.find({x.second,x.first })!=sop.end();}) ;
  14. }
  15.  
  16. int main() {
  17. SOP test1 { {1,3},{2,4},{5,7},{7,5}, {4,2}, {3,1} };
  18. SOP test2 { {1,3},{2,4},{5,7},{7,5}, {4,2}, {3,1}, {8,4} };
  19.  
  20. cout << is_symetric(test1)<<endl;
  21. cout << is_symetric(test2)<<endl;
  22. return 0;
  23. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
1
0