#include #include #include #include #include #include #include #include #include #include #include using namespace std; int main(int argc, char** argv){ if(argc < 7){ cerr << "Usage: " << argv[0] << " SEED K R TMAX CMAX WMAX [EXTRAS]\n"; return 1; } long long SEED = stoll(argv[1]); int K = stoi(argv[2]); int R = stoi(argv[3]); int TMAX= stoi(argv[4]); int CMAX= stoi(argv[5]); int WMAX= stoi(argv[6]); int EXTRAS = (argc >= 8 ? stoi(argv[7]) : -1); if(K < 3){ cerr << "Error: K must be >= 3 to isolate pub 1 and still have at least one road.\n"; return 1; } if(EXTRAS < 0) EXTRAS = K; // sensible default mt19937_64 rng(SEED); auto rnd = [&](int lo,int hi){ uniform_int_distribution d(lo,hi); return d(rng); }; // 1) Drinking times cout << R << "\n"; for(int i=1;i<=R;i++){ int ti = max(1, min(TMAX, rnd(1, max(1,TMAX)))); cout << ti << (i==R?'\n':' '); } // 2) Pubs & closing times cout << K << "\n"; for(int i=1;i<=K;i++){ int ci = max(1, min(CMAX, rnd(1, max(1,CMAX)))); cout << ci << (i==K?'\n':' '); } // 3) Build edges among nodes 2..K only (pub 1 is isolated) vector> E; E.reserve((size_t)(K-1 + max(0,EXTRAS))); // Make {2..K} connected: random tree for(int v=3; v<=K; ++v){ int u = rnd(2, v-1); int w = rnd(1, max(1,WMAX)); E.emplace_back(u, v, w); } // Add extra edges among {2..K}; allow duplicates const size_t EDGE_CAP = 90000; for(int e=0; e2) b=a-1; else b=a+1; } // ensure a!=b if(a>b) swap(a,b); int w = rnd(1, max(1,WMAX)); E.emplace_back(a,b,w); } // Optional sprinkle of duplicates to increase density slightly (up to 10%) if(!E.empty()){ size_t addm = min(E.size()/10 + 5, (EDGE_CAP > E.size() ? EDGE_CAP - E.size() : 0)); for(size_t i=0; i=3 -> tree has K-2 >= 1 edges) if(E.empty()){ // Fallback (shouldn't happen): connect 2--3 E.emplace_back(2,3, rnd(1, max(1,WMAX))); } cout << E.size() << "\n"; for(auto &e : E){ int a,b,w; tie(a,b,w)=e; cout << a << " " << b << " " << w << "\n"; } return 0; }