1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
| #include <bits/stdc++.h> using namespace std; static unsigned long _next = 1; const int INF = 1e8;
int myrand() { _next = _next * 1103515245 + 12345; return((unsigned)(_next/65536) % 32768); }
const int N = 1001; double I[1024][N]; int n, s, p, t; double dt;
double v[N<<1], u[N<<1], a[N<<1], b[N<<1], c[N<<1], d[N<<1]; int r[N<<1]; int h[N<<1], D[N<<1], idx, e[N<<1], ne[N<<1]; double w[N<<1]; int cnt[N<<1]; void add(int aa, int bb, double ww, int DD) { D[idx] = DD, w[idx] = ww, e[idx] = bb, ne[idx] = h[aa], h[aa] = idx++; }
int main() { scanf("%d%d%d%d", &n, &s, &p, &t); scanf("%lf", &dt); memset(h, -1, sizeof h); int sum = 0; int iidx = 0, max_d = 0; while(true) { int rn; double vv, uu, aa, bb, cc, dd; scanf("%d%lf%lf%lf%lf%lf%lf", &rn, &vv, &uu, &aa, &bb, &cc, &dd); sum += rn; for(int i = 0; i < rn; ++i) { v[iidx] = vv, u[iidx] = uu, a[iidx] = aa, b[iidx] = bb, c[iidx] = cc, d[iidx] = dd; iidx++; } if(sum == n) break; } for(int i = n; i < n + p; ++i) scanf("%d", &r[i]);
for(int i = 0; i < s; ++i) { int ss, tt, DD; double ww; scanf("%d%d%lf%d", &ss, &tt, &ww, &DD); max_d = max(max_d, DD+1); add(ss, tt, ww, DD); }
for(int i = 0; i < t; ++i) { int tt = i % max_d; for(int j = n; j < n + p; ++j) { if(r[j] > myrand()) { for(int k = h[j]; k != -1; k = ne[k]) { I[(tt+D[k]) % max_d][e[k]] += w[k]; } cnt[j]++; } } for(int j = 0; j < n; ++j) { double vv = v[j], uu = u[j]; v[j] = vv + dt * (0.04 * vv * vv + 5 * vv + 140 - uu) + I[tt][j]; u[j] = uu + dt * a[j] * (b[j] * vv - uu); if(v[j] >= 30) { for(int k = h[j]; k != -1; k = ne[k]) { I[(tt+D[k]) % max_d][e[k]] += w[k]; } v[j] = c[j], u[j] += d[j]; cnt[j]++; } } memset(I[tt], 0, sizeof I[tt]); } double minv = INF, maxv = -INF; int maxc = -INF, minc = INF; for(int i = 0; i < n; ++i) { minv = min(minv, v[i]); maxv = max(maxv, v[i]); maxc = max(maxc, cnt[i]); minc = min(minc, cnt[i]); } printf("%lf %lf\n%d %d", minv, maxv, minc, maxc); return 0; }
|