bipartite-graph-validator.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #include "testlib.h"
  2. #include <iostream>
  3. #include <sstream>
  4. #include <fstream>
  5. #include <iomanip>
  6. #include <string>
  7. #include <cstdlib>
  8. #include <cstdio>
  9. #include <cstring>
  10. #include <cmath>
  11. #include <ctime>
  12. #include <climits>
  13. #include <cassert>
  14. #include <vector>
  15. #include <queue>
  16. #include <stack>
  17. #include <deque>
  18. #include <set>
  19. #include <map>
  20. #include <bitset>
  21. #include <utility>
  22. #include <algorithm>
  23. #define forn(i, n) for (int i = 0; i < int(n); i++)
  24. using namespace std;
  25. int main()
  26. {
  27. registerValidation();
  28. int n = inf.readInt(1, 400, "n");
  29. inf.readSpace();
  30. int m = inf.readInt(1, 400, "m");
  31. inf.readSpace();
  32. int k = inf.readInt(0, n * m, "k");
  33. inf.readEoln();
  34. set<pair<int,int> > edges;
  35. forn(i, k)
  36. {
  37. int a = inf.readInt(1, n, "a_i");
  38. inf.readSpace();
  39. int b = inf.readInt(1, m, "b_i");
  40. inf.readEoln();
  41. ensuref(edges.count(make_pair(a, b)) == 0, "Graph can't contain multiple edges between a pair of vertices");
  42. edges.insert(make_pair(a, b));
  43. }
  44. inf.readEof();
  45. return 0;
  46. }