#include<bits/stdc++.h>
using namespace std;
long long mod=1e9+7;
long long n,c,a[1005],b[1005],q,dp[1005][30];
int f(int x,int cal)
{
if(x>=n)
{
if(cal>=c)return 1;
else return 0;
}
if(dp[x][cal]!=-1)return dp[x][cal];
long long num=0;
num+=a[x]*f(x+1,cal+1);
num%=10007;
num+=b[x]*f(x+1,cal);
num%=10007;
return dp[x][cal]=num;
}
int main()
{
cin>>n>>c;
for(int i=0;i<n;i++)cin>>a[i];
for(int i=0;i<n;i++)cin>>b[i];
cin>>q;
for(int i=0;i<q;i++)
{
memset(dp,-1,sizeof dp);
long long x,y,z;
cin>>x>>y>>z;
a[x-1]=y;
b[x-1]=z;
cout<<f(0,0)<<endl;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
555 ms |
760 KB |
Output isn't correct |
2 |
Incorrect |
626 ms |
760 KB |
Output isn't correct |
3 |
Incorrect |
416 ms |
632 KB |
Output isn't correct |
4 |
Runtime error |
4 ms |
504 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
5 |
Runtime error |
4 ms |
504 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
6 |
Runtime error |
4 ms |
504 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
7 |
Runtime error |
4 ms |
504 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
8 |
Runtime error |
3 ms |
504 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
9 |
Runtime error |
3 ms |
504 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
10 |
Runtime error |
4 ms |
504 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |