Advertisement
willy108

Convex Hull Point Generation

Jul 31st, 2021
1,657
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.67 KB | None | 0 0
  1. #include <iostream>
  2. #include <random>
  3. #include <chrono>
  4.  
  5. #define uid(a, b) uniform_int_distribution<int>(a, b)(rng)
  6. using namespace std;
  7. mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
  8.  
  9. //http://www.cplusplus.com/reference/random/uniform_int_distribution/
  10.  
  11. int main(){
  12.     int n, d;
  13.     cin >> n >> d;
  14.     //n will be <= 5e5, d will be <= 1e9
  15.     set<pair<int, int>> vis;
  16.     for(int i = 0; i<n; i++){
  17.         int a = uid(1, d), b = uid(1, d);
  18.         while(vis.count(make_pair(a, b))){
  19.             a = uid(1, d), b = uid(1, d);
  20.         }
  21.         cout << a << " " << b << "\n";
  22.         vis.insert(make_pair(a, b));
  23.     }
  24.  
  25.     return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement