提交时间:2022-05-13 13:31:20

运行 ID: 49773

#include <bits/stdc++.h> #define ll long long #define mod (long long)(1e9+7) using namespace std; int n, m, t, x, y, a[200007] = {0,1}; ll xdt[400028]; void Build(ll root, ll l, ll r) { ll mid = (l+r)>>1; if(l == r) { xdt[root] = a[l]%mod; return; } Build(root<<1, l, mid); Build(root<<1|1, mid+1, r); xdt[root] = xdt[root<<1]*xdt[root<<1|1]%mod; } void Update(ll root, ll l, ll r, ll pos) { ll mid = (l+r)>>1; if(l>pos || r<pos) return; if(l == r) { xdt[root] = (xdt[root]+1)%mod; return; } Update(root<<1, l, mid, pos); Update(root<<1|1, mid+1, r, pos); xdt[root] = xdt[root<<1]*xdt[root<<1|1]%mod; } int main() { scanf("%lld%lld%lld", &n, &m, &t); for(int i=1; i<=m; i++) { scanf("%lld%lld", &x, &y); a[y]++; } a[1] = 1; Build(1, 1, n); printf("%lld\n", xdt[1]); for(int i=1; i<=t; i++) { scanf("%lld%lld", &x, &y); Update(1, 1, n, y); printf("%lld\n", xdt[1]); } return 0; }