bipartite-graph-validator.cpp 742 B

12345678910111213141516171819202122232425262728293031
  1. #include "testlib.h"
  2. #include <set>
  3. using namespace std;
  4. int main(int argc, char *argv[]) {
  5. registerValidation(argc, argv);
  6. int n = inf.readInt(1, 400, "n");
  7. inf.readSpace();
  8. int m = inf.readInt(1, 400, "m");
  9. inf.readSpace();
  10. int k = inf.readInt(0, n * m, "k");
  11. inf.readEoln();
  12. set<pair<int, int>> edges;
  13. for (int i = 0; i < k; i++) {
  14. int a = inf.readInt(1, n, "a_i");
  15. inf.readSpace();
  16. int b = inf.readInt(1, m, "b_i");
  17. inf.readEoln();
  18. ensuref(edges.count(make_pair(a, b)) == 0,
  19. "Graph can't contain multiple edges between a pair of vertices");
  20. edges.insert(make_pair(a, b));
  21. }
  22. inf.readEof();
  23. }