-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestcase_gen.cpp
47 lines (40 loc) · 1004 Bytes
/
testcase_gen.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main()
{
srand(time(NULL));
long int nr = 1000;
long int nc = 1000;
float sparsity = 0.05;
double ne = 1.0*sparsity*nr*nc;
// cout << ne << endl;
int count = 0;
vector< pair<int,int> > posi;
vector<int> perm(nr);
for(int i=0; i<nr; i++)
perm[i] = i;
for(int i=0; i<nr; i++)
{
random_shuffle(perm.begin(), perm.end());
int var = -20 + rand()%40;
float el = 1.0*sparsity*(100+var)/100;
el *= nc;
// cout << el << endl;
for(int j=0; j< el; j++)
{
posi.push_back(make_pair(i+1, perm[j]+1));
count++;
if(count >= ne)
break;
}
if(count >= ne)
break;
}
cout << nr << " " << nc << " " << count << endl;
for(int i=0; i<posi.size(); i++)
{
cout << posi[i].first << " " << posi[i].second << endl;
}
}