gen-bipartite-graph.cpp 735 B

12345678910111213141516171819202122232425262728293031323334
  1. #include "testlib.h"
  2. #include <vector>
  3. #include <set>
  4. using namespace std;
  5. int main(int argc, char *argv[]) {
  6. registerGen(argc, argv, 1);
  7. int n = opt<int>(1);
  8. int m = opt<int>(2);
  9. size_t k = opt<int>(3);
  10. int t = rnd.next(-2, 2);
  11. set<pair<int, int>> edges;
  12. while (edges.size() < k) {
  13. int a = rnd.wnext(n, t);
  14. int b = rnd.wnext(m, t);
  15. edges.insert(make_pair(a, b));
  16. }
  17. vector<pair<int, int>> e(edges.begin(), edges.end());
  18. shuffle(e.begin(), e.end());
  19. vector<int> pa = rnd.perm(n, 1);
  20. vector<int> pb = rnd.perm(m, 1);
  21. println(n, m, e.size());
  22. for (auto edge: e)
  23. println(pa[edge.first], pb[edge.second]);
  24. }