题解

$$f_{x,y}=p_xf_{x-1,y-1}+(1-p_x)f_{x-1,y-1}$$

$$p_x=(\sum_{a_{x,i} < A} p_{x,i})/sum_x$$

$$g_x=f_{x-1}p_i+f_x(1-p_i)$$

$$f_{x}=\frac{g_x-p_if_{x-1}}{1-p_i}$$

#include<bits/stdc++.h>
#define fo(i, a, b) for (int i = (a); i <= (b); ++i)
#define fd(i, a, b) for (int i = (a); i >= (b); --i)
#define edge(i, u) for (int i = head[u], v = e[i].v; i; i = e[i].nxt, v = e[i].v)
#define pb push_back
#define F first
#define S second
#define ll long long
#define inf 1000000007
#define mp std::make_pair
#define ls (u << 1)
#define rs (u << 1 | 1)
#define mod 1000000007
#define eps 1e-4
#define N 200005
struct node {
int id;
ll a, g, p;
friend bool operator < (node x, node y) { return x.a < y.a; }
} q[N];
int t, n, m;
ll inv[N], ans[N], f[N], g[N], now[N], sum[N], v[N];
inline void ins (int x)
{
ll pi = now[x] * inv[sum[x]] % mod, api = (1 - pi + mod) % mod;
fo (x, 0, n - 1) g[x] = (f[x - 1] * pi + f[x] * api) % mod;
}
inline void del (int x)
{
ll pi = now[x] * inv[sum[x]] % mod, invapi = inv[sum[x] - now[x]] * sum[x] % mod;
f[0] = g[0] * invapi % mod;
fo (x, 1, n - 1) f[x] = (g[x] - f[x - 1] * pi % mod + mod) * invapi % mod;
}
int main ()
{
inv[1] = 1;
fo (i, 2, 2e5) inv[i] = mod - mod / i * inv[mod % i] % mod;
scanf("%d", &n);
fo (i, 1, n)
{
scanf("%d", &m);
while (m--)
{
++t;
scanf("%lld %lld %lld", &q[t].a, &q[t].g, &q[t].p);
sum[i] += q[t].p;
q[t].id = i;
q[t].g = (100 - q[t].g) * inv[100] % mod;
}
}
std::sort(q + 1, q + t + 1);
fo (i, 1, n) scanf("%lld", &v[i]);
g[0] = 1;
fo (i, 1, t)
{
del(q[i].id);
fo (x, 0, n - 1)
(ans[q[i].id] += f[x] * v[n - x] % mod * q[i].g % mod * q[i].p % mod * inv[sum[q[i].id]]) %= mod;
now[q[i].id] += q[i].p;
ins(q[i].id);
}
fo (i, 1, n) printf("%lld\n", ans[i]);
return 0;
}