提交时间:2022-05-05 13:18:28
运行 ID: 49269
#include<bits/stdc++.h> using namespace std; const int M=1e9+7; int f[200003]; int Read(){ int sum=0; char ch=getchar(); while(ch<'0' || ch>'9') ch=getchar(); while(ch>='0' && ch<='9') sum=sum*10+ch-'0',ch=getchar(); return sum; } int Inv(int x,int p){ long long ans=1; while(p) { if(p>>1) ans=ans*x%M; x=x*x%M; p>>=1; } return ans; } int main(){ int n,m,T,x,y,ans=1; n=Read(),m=Read(),T=Read(); while(m--) x=Read(),y=Read(),++f[y]; while(n--) if(f[n+1]) ans=ans*f[n+1]%M; cout<<ans<<'\n'; while(T--) { x=Read(),y=Read(); if(f[y]) ans=ans/Inv(f[y],M-2)%M; f[y]=(f[y]+1)%M; ans=ans*f[y]%M; cout<<ans<<'\n'; } return 0; }