有向图和无向图同样适用的数据生成器,可生成随机图
前段时间出校内模拟赛的时候才学怎么写的。(深感不会出数据的无力,逃
CODE:
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<set>
#include<ctime>
#include<iostream>
using namespace std;
int n,m,s,T;
inline int random() {
static int seed = s;
return seed = (int)(seed*48271ll%2147483647);
}
set<int>to[100005];//去重
int main() {
srand ( time ( NULL ) ) ;
cin >> T;
cout << T << endl;
while(T--) {
s = rand();
n = 96;
m = 102;
printf("%d %d \n",n,m);
for(int i = 1 ; i <= m ; i++) {
int u = random() % n + 1;
int v = random() % n + 1;
while(to[u].find(v) != to[u].end() || u == v) {
u = random() % n + 1;
v = random() % n + 1;
}
printf("%d %d\n",u,v);
to[u].insert(v);
}
printf("\n");
}
return 0;
}