#include #include #include #include #include #include #include using namespace std; //typedef long long int lli; //typedef pair prii; #define lli long long int #define prii pair struct edge { int from, to, weight; }; inline edge Edge(int from, int to, long long int dis) { edge now; now.from = from, now.to = to, now.weight = dis; return now; } struct data_maker { // output file name char ofile[1001]; // ranges maker saved vector Ranges; // the gragh which has been saved. vector Gragh; map Saved; // flow of output to the ofile FILE *fout; // integer rand limit // 19260817 for its origin lli Integer_rand_limit; // integer rand limit // 19260817 for its origin // 114514 for not to give a limit lli edge_rand_limit; // quick scanner of an integer. // warn: it will read all the charactors that is not digits. // you can just us it like scan an integer. template inline Tp NextInt() { Tp num = 0; char ch = getchar(); bool flag = false; while (!isdigit(ch)) flag |= ch == '-', ch = getchar(); while (isdigit(ch)) num = (num << 1) + (num << 3) + (ch ^ 48), ch = getchar(); return flag ? -num : num; } // to get the version on your console. inline void Version() { puts("Jelly Data Maker version 0.3.2."); puts("All rights reserved."); } // to set the integers' rand limit inline void Int_range(lli __limit__) { this->Integer_rand_limit = __limit__; } // to set limits of the integers as the weight of edges inline void edge_range(lli __weight_limit__) { this->edge_rand_limit = __weight_limit__; } // to reset the output file name to __o_file_name[] inline void reset_ofile(const char *__o_file_name__) { sprintf(this->ofile, "%s", __o_file_name__); delete fout; fout = fopen(__o_file_name__, "w+"); } // to get the integer of random inline lli Rand(lli __limits__) { return ((rand() << 16 | rand()) & 0x7fffffff) % __limits__ + 1; } //to make an array if n integers! inline void Integer_array(int n) { for (int i = 1; i <= n; i++) { fprintf(fout, "%lld ", this->Rand(Integer_rand_limit)); } } inline lli range_rand(int __l_limit__, int __r_limit__) { return __l_limit__ + Rand(__r_limit__ - __l_limit__); } // to make some integer ranges inline void Ranges_maker(int n, int __l_limit__ = 1, int __r_limit__ = 19260817) { this->Ranges.clear(); for (int i = 1; i <= n; i++) { int l = this->range_rand(__l_limit__, __r_limit__); Ranges.push_back(make_pair(l, this->range_rand(l, __r_limit__))); } } // to make a tree as a undirected gragh // includes n nodes // and it must be in only one group inline void tree_maker(int n) { // version 0.2.1 has been purged this->Gragh.clear(); for (int i = 2; i <= n; i++) { Gragh.push_back(Edge(i, this->Rand(i - 1), 0)); } } // to make a undirected gragh // include n nodes and m edges inline void ugragh_maker(int n, int m) { // version 0.2.1 has been purged this->Gragh.clear(); this->Saved.clear(); for (int i = 2; i <= n && i <= m + 1; i++) { edge now = Edge(i, this->Rand(i - 1), this->edge_rand_limit == 114514 ? 0 : this->Rand(this->edge_rand_limit)); this->Gragh.push_back(now); this->Saved[make_pair(now.from, now.to)] = true; } m -= n - 1; for (int i = 1; i <= m; i++) { int from = i, to = i; while (from == to || this->Saved[make_pair(from, to)] == true) from = this->Rand(n), to = this->Rand(n); edge now = Edge(from, to, this->edge_rand_limit == 114514 ? 0 : this->Rand(this->edge_rand_limit)); Gragh.push_back(now); Saved[make_pair(from, to)] = true; } } // to origin data maker's settings // output.txt for its remote output // integer's origin for 19260817 data_maker() { for (int i = 0; i <= 1000; i++) ofile[i] = 0; sprintf(ofile, "%s", "output.txt"); fout = fopen(ofile, "w+"); Integer_rand_limit = 19260817; edge_rand_limit = 19260817; } // to origin data maker's settings with output file name(__o_file_name[]) // output.txt for its remote output // integer's origin for 19260817 data_maker(const char *__o_file_name) { for (int i = 0; i <= 1000; i++) ofile[i] = 0; sprintf(ofile, "%s", __o_file_name); fout = fopen(ofile, "w+"); Integer_rand_limit = 19260817; edge_rand_limit = 19260817; } };