这题纯暴力竟然能过……
1 //minamoto 2 #include<cstdio> 3 #include<iostream> 4 #define mul(a,b) (1ll*a*b%P) 5 using namespace std; 6 #define getc() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++) 7 char buf[1<<21],*p1=buf,*p2=buf; 8 int read(){ 9 #define num ch-'0' 10 char ch;bool flag=0;int res; 11 while(!isdigit(ch=getc())) 12 (ch=='-')&&(flag=true); 13 for(res=num;isdigit(ch=getc());res=res*10+num); 14 (flag)&&(res=-res); 15 #undef num 16 return res; 17 } 18 char sr[1<<21],z[20];int C=-1,Z; 19 inline void Ot(){fwrite(sr,1,C+1,stdout),C=-1;} 20 void print(int x){ 21 if(C>1<<20)Ot();if(x<0)sr[++C]=45,x=-x; 22 while(z[++Z]=x%10+48,x/=10); 23 while(sr[++C]=z[Z],--Z);sr[++C]=' '; 24 } 25 const int N=2e5+5,P=1e9+7; 26 int n,m,a[N],b[N],c[N],ans=1; 27 int ksm(int a,int b){ 28 int res=1; 29 while(b){ 30 if(b&1) res=mul(res,a); 31 a=mul(a,a),b>>=1; 32 } 33 return res; 34 } 35 int main(){ 36 // freopen("testdata.in","r",stdin); 37 n=read(),m=read(); 38 for(int i=1;i<=n;++i) 39 a[i]=read(),c[i]=max(c[i-1],a[i]); 40 for(int i=1;i<=n;++i) 41 b[i]=read(),ans=mul(min(b[i],c[i]),ans); 42 while(m--){ 43 int op=read(),x=read(),y=read(); 44 if(op==1){ 45 if(b[x]<c[x]){ 46 ans=mul(ans,ksm(b[x],P-2)); 47 ans=mul(ans,min(y,c[x])); 48 } 49 b[x]=y; 50 }else{ 51 a[x]=y; 52 while(c[x]<y&&x<=n){ 53 if(c[x]<b[x]){ 54 ans=mul(ans,ksm(c[x],P-2)); 55 ans=mul(ans,min(y,b[x])); 56 }c[x++]=y; 57 } 58 } 59 print(ans); 60 } 61 return Ot(),0; 62 }