// gen_random.cc #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; static inline long long clampll(long long x, long long lo, long long hi){ return max(lo, min(hi, x)); } int main(int argc, char** argv){ if(argc < 9){ cerr << "Usage: " << argv[0] << " SEED K M R TMAX CMAX WMAX CONNECTED(0/1)\n"; return 1; } long long SEED = stoll(argv[1]); int K = stoi(argv[2]); long long Mreq = stoll(argv[3]); int R = stoi(argv[4]); int TMAX = stoi(argv[5]); int CMAX = stoi(argv[6]); int WMAX = stoi(argv[7]); int CONNECTED = stoi(argv[8]); mt19937_64 rng(SEED); auto rnd = [&](long long lo, long long hi){ uniform_int_distribution d(lo,hi); return (int)d(rng); }; const long long MAXE = 1LL*K*(K-1)/2; long long M = clampll(Mreq, 0, min(90000, MAXE)); // Times cout << R << "\n"; for(int i=1;i<=R;i++){ int ti = max(1, rnd(1, TMAX)); cout << ti << (i==R?'\n':' '); } // Pubs & closings cout << K << "\n"; for(int i=1;i<=K;i++){ int ci = max(1, rnd(1, CMAX)); cout << ci << (i==K?'\n':' '); } vector> edges; edges.reserve(M); set> used; if(CONNECTED && K>=2){ // random spanning tree first vector parent(K+1,-1); iota(parent.begin(), parent.end(), 0); // Build by connecting i to random [1..i-1] for(int v=2; v<=K; ++v){ int u = rnd(1, v-1); int w = rnd(1, WMAX); if(!used.count({min(u,v), max(u,v)})){ used.insert({min(u,v), max(u,v)}); edges.push_back({u<<16 | v, w}); // store endpoints packed } } } // Fill remaining edges at random while((long long)edges.size() < M){ int a = rnd(1,K), b = rnd(1,K); if(a==b) continue; int w = rnd(1,WMAX); edges.push_back({a<<16 | b, w}); } cout << edges.size() << "\n"; for(auto &e: edges){ int a = (e.first >> 16) & 0xFFFF; int b = (e.first) & 0xFFFF; cout << a << " " << b << " " << e.second << "\n"; } return 0; }