Advertisement
Guest User

Untitled

a guest
May 2nd, 2011
306
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <stdio.h>
  4. #include <vector>
  5. #include <algorithm>
  6. #include <string>
  7. #include <cmath>
  8. #include <cstring>
  9. #include <queue>
  10. #include <stack>
  11. #include <deque>
  12. #include <set>
  13. #include <map>
  14. #include <time.h>
  15. #include <stdlib.h>
  16. using namespace std;
  17.  
  18. #define mp make_pair
  19. #define pb push_back
  20. #define vi vector <int>
  21. #define rep(i,n) for(int i = 0; i < n; i++)
  22. #define read(a) rep(i, a.size()) fin >> a[i];
  23. #define write(a) rep(i, a.size()) fout << a[i] << ' '; fout << endl;
  24. #define fi first
  25. #define se second
  26. #define ll long long
  27. const int inf = 2000000000, mod = 1000000007;
  28. const double eps = 0.000001;
  29.  
  30. int main()
  31. {
  32. ofstream fout ("input.txt");
  33. srand(time(NULL));
  34. int n = 25000, m = 100000;
  35. fout << n << ' ' << m << endl;
  36. map <pair<int, int>, bool> was;
  37. vector <int> dsu(n, 0);
  38. for (int i = n / 2 + 1; i < n; i++)
  39. dsu[i] = 1;
  40. for (int i = n - n / 4; i < n; i++)
  41. dsu[i] = 2;
  42.  
  43. for (int i = 0; i < m; i++)
  44. {
  45. int x = rand() % n, y = rand() % n;
  46. if (dsu[x] != dsu[y] || x == y || was[make_pair(x, y)])
  47. {
  48. i--;
  49. continue;
  50. }
  51. was[make_pair(x, y)] = true;
  52. fout << x + 1 << ' ' << y + 1 << endl;
  53. }
  54. return 0;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement