Submission #1161871


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll mod = 1e9+7;
ll dp[500][500];
ll A[500];
ll B[500];
ll powdp[500][500];


ll modPow(ll a, ll b) {
	if (powdp[a][b] > -1) return powdp[a][b];
	ll ret = a;
	if (b == 0) ret = 1;
	if (b > 1) {
		for (ll i = 0; i < b - 1; ++i) {
			if (powdp[a][i+2] > -1) {ret = powdp[a][i+2]; continue;}
			ret *= a;
			ret %= mod;
			powdp[a][i+2] = ret;
		}
	}
	return ret;
}

int main() {
	ll N, C;
	cin >> N >> C;
	for (ll i = 0; i < N; ++i) cin >> A[i];
	for (ll i = 0; i < N; ++i) cin >> B[i];
	
	memset(dp, 0, sizeof(dp));
	memset(powdp, -1, sizeof(powdp));
	dp[0][0] =  1;
	for (ll a = 0; a <= N; ++a) {
		for (ll b = 0; b <= C; ++b) {
			ll sum = 0;
			for (ll c = 0; c < b; ++c) {sum += dp[a][c] * modPow(A[a], (b - c)); sum %= mod;}
			dp[a+1][b] = dp[a][b] + sum;
			dp[a+1][b] %= mod;
		}
	}
	cout << dp[N][C] % mod << endl;
}

Submission Info

Submission Time
Task C - Be Together
User Veronica
Language C++14 (GCC 5.4.1)
Score 0
Code Size 936 Byte
Status RE
Exec Time 98 ms
Memory 4096 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 200
Status
AC × 1
WA × 3
AC × 2
WA × 12
RE × 1
Set Name Test Cases
Sample 0_000.txt, 0_001.txt, 0_002.txt, 0_003.txt
All 0_000.txt, 0_001.txt, 0_002.txt, 0_003.txt, 1_004.txt, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt, 1_010.txt, 1_011.txt, 1_012.txt, 1_013.txt, 1_014.txt
Case Name Status Exec Time Memory
0_000.txt WA 3 ms 4096 KB
0_001.txt WA 3 ms 4096 KB
0_002.txt WA 3 ms 4096 KB
0_003.txt AC 3 ms 4096 KB
1_004.txt WA 3 ms 4096 KB
1_005.txt WA 3 ms 4096 KB
1_006.txt WA 3 ms 4096 KB
1_007.txt WA 10 ms 4096 KB
1_008.txt WA 3 ms 4096 KB
1_009.txt WA 3 ms 4096 KB
1_010.txt RE 98 ms 4096 KB
1_011.txt WA 3 ms 4096 KB
1_012.txt WA 3 ms 4096 KB
1_013.txt WA 3 ms 4096 KB
1_014.txt AC 3 ms 4096 KB