提交时间:2022-08-20 21:43:53
运行 ID: 55736
#include<bits/stdc++.h> using namespace std; const int maxn=200010; const int mod=1e9+7; inline int read(){ int x=0; char c=getchar(); for(;!(c>='0'&&c<='9');c=getchar()); for(;c>='0'&&c<='9';c=getchar()) x=(x<<1)+(x<<3)+c-'0'; return x; } int cnt[maxn],n,m,T,ans=1; int fastpow(int n,int m,int x=1){ for(;m;n=n*1ll*n%mod,m>>=1) if(m&1) x=x*1ll*n%mod; return x; } int Inv(int x){return fastpow(x,mod-2);} int main(){ // freopen("graph.in","r",stdin); // freopen("graph.out","w",stdout); n=read(),m=read(),T=read(); for(int i=1;i<=m;i++) read(),cnt[read()]++; for(int i=2;i<=n;i++) ans=ans*1ll*cnt[i]%mod; printf("%d\n",ans); int x; while(T--){ read(),x=read(); ans=ans*1ll*Inv(cnt[x])%mod; cnt[x]++,ans=ans*1ll*cnt[x]%mod; printf("%d\n",ans); } return 0; }