Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- #include <set>
- #include <cstdlib>
- #include <algorithm>
- using namespace std;
- typedef pair<int,int> II;
- typedef set<II>::iterator iter;
- int rand(int a, int b){
- return rand() % (b - a + 1) + a;
- }
- int main(){
- int n = 100000, m = 10000;
- set<II> used;
- for(int i = 0; i < m; ++i){
- while(true){
- int a = rand(1, n);
- int b = rand(1, n);
- if(a > b) swap(a, b);
- iter pos = used.lower_bound(II(a, b));
- if(pos != used.end() and *pos == II(a, b)){
- // we have generated this edge!
- // try again
- }else{
- printf("%d %d\n", a, b);
- used.insert(II(a, b));
- break;
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement