#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using ll = long long; const ll INF = (1LL<<60); int main(int argc, char** argv){ if(argc < 8){ cerr << "Usage: " << argv[0] << " SEED K R TMAX CMAX WMAX TIGHT_PERCENT\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 TIGHT = stoi(argv[7]); mt19937_64 rng(SEED); auto rnd = [&](int lo,int hi){ uniform_int_distribution d(lo,hi); return d(rng); }; vector t(R+1); cout << R << "\n"; long long sumT = 0; for(int i=1;i<=R;i++){ t[i] = rnd(1, max(1,TMAX)); sumT += t[i]; cout << t[i] << (i==R?'\n':' '); } // Build connected graph: tree + ~K extra edges vector>> adj(K+1); vector> E; auto add = [&](int a,int b,int w){ adj[a].push_back({b,w}); adj[b].push_back({a,w}); E.emplace_back(a,b,w); }; for(int v=2; v<=K; ++v){ int u = rnd(1, v-1); int w = rnd(1, max(1,WMAX)); add(u,v,w); } int extras = max(0, K); set> used; for(auto &e: E){ int a,b,w; tie(a,b,w)=e; if(a>b) swap(a,b); used.insert({a,b}); } while(extras--){ int a = rnd(1,K), b = rnd(1,K); if(a==b) continue; int x=a,y=b; if(x>y) swap(x,y); if(used.count({x,y})) continue; used.insert({x,y}); int w = rnd(1, max(1,WMAX)); add(a,b,w); } // Dijkstra from 1 vector dist(K+1, INF); priority_queue, vector>, greater>> pq; dist[1] = 0; pq.push({0,1}); while(!pq.empty()){ auto [du,u]=pq.top(); pq.pop(); if(du!=dist[u]) continue; for(auto [v,w]: adj[u]){ if(dist[v] > du + w){ dist[v] = du + w; pq.push({dist[v], v}); } } } cout << K << "\n"; double tight_frac = max(0, TIGHT) / 100.0; for(int i=1;i<=K;i++){ long long base = (dist[i]>=INF/2 ? 0 : dist[i]); long long slack = (long long)ceil(tight_frac * (double)sumT); long long noise = rnd(0, max(1,TMAX)); long long ci = base + slack + noise; if(ci < 1) ci = 1; if(ci > CMAX) ci = CMAX; cout << ci << (i==K?'\n':' '); } cout << E.size() << "\n"; for(auto &e: E){ int a,b,w; tie(a,b,w)=e; cout << a << " " << b << " " << w << "\n"; } return 0; }