This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <stdio.h>
#include <vector>
using namespace std;
#define MAXN 10004
typedef long long lld;
const int MOD = 1e9 + 7;
int T, N, A, none, ans;
int P[MAXN][10], Q[MAXN];
void dfs(int t, vector <int> &v, int p)
{
int i, j;
if (t == T){
int x = 1;
for (i=0;i<10;i++) x = (lld)x*v[i]%MOD;
ans = (ans+(lld)x*p%MOD)%MOD;
return;
}
for (i=1;i<=N;i++){
for (j=0;j<10;j++) v[j] = (v[j]+P[i][j])%MOD;
dfs(t+1, v, (lld)p*Q[i]%MOD);
for (j=0;j<10;j++) v[j] = (v[j]-P[i][j]+MOD)%MOD;
}
dfs(t+1, v, (lld)p*none%MOD);
}
int main()
{
int i, j, k;
scanf("%d%d%d", &T, &N, &A);
none = A;
for (i=1;i<=N;i++){
scanf("%d", Q+i);
for (j=0;j<10;j++){
scanf("%d", P[i]+j);
}
none -= Q[i];
}
vector <int> arr(10,1);
dfs(0, arr, 1);
printf("%d\n", ans);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |