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