Submission #1188066


Source Code Expand

#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> P;

const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS  = 1e-10;

int n, c;
int a[400], b[400];
ll dp[401][401];

ll dfs(int pos, int cnt) {
	if (pos == n) return cnt == c;
	if (~dp[pos][cnt]) return dp[pos][cnt];
	
	ll res = 0, p = 1;
	
	REP(i, c - cnt + 1) {
		(res += dfs(pos + 1, cnt + i) * p % MOD) %= MOD;
		p = p * a[pos] % MOD;
	}
	
	return dp[pos][cnt] = res;
}

int main() {
	cin >> n >> c;
	REP(i, n) scanf("%d", a + i);
	REP(i, n) scanf("%d", b + i);
	
	bool ok = true;
	REP(i, n) if (a[i] != b[i]) ok = false;
	assert(ok);
	
	fill(dp[0], dp[n + 1], -1);
	
	cout << dfs(0, 0) << endl;
	
	return 0;
}

Submission Info

Submission Time
Task E - Children and Candies
User tkmst201
Language C++14 (GCC 5.4.1)
Score 400
Code Size 1146 Byte
Status RE
Exec Time 288 ms
Memory 1536 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:41:30: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  REP(i, n) scanf("%d", a + i);
                              ^
./Main.cpp:42:30: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  REP(i, n) scanf("%d", b + i);
                              ^

Judge Result

Set Name Sample Subtask All
Score / Max Score 0 / 0 400 / 400 0 / 400
Status
AC × 2
RE × 3
AC × 12
AC × 14
RE × 16
Set Name Test Cases
Sample 0_000.txt, 0_001.txt, 0_002.txt, 0_003.txt, 0_004.txt
Subtask 0_001, 0_003, 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, 1_015.txt, 1_016.txt
All 0_000.txt, 0_001.txt, 0_002.txt, 0_003.txt, 0_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, 1_015.txt, 1_016.txt, 2_017.txt, 2_018.txt, 2_019.txt, 2_020.txt, 2_021.txt, 2_022.txt, 2_023.txt, 2_024.txt, 2_025.txt, 2_026.txt, 2_027.txt, 2_028.txt, 2_029.txt
Case Name Status Exec Time Memory
0_000.txt RE 99 ms 256 KB
0_001.txt AC 1 ms 256 KB
0_002.txt RE 99 ms 256 KB
0_003.txt AC 1 ms 256 KB
0_004.txt RE 100 ms 256 KB
1_005.txt AC 1 ms 256 KB
1_006.txt AC 1 ms 256 KB
1_007.txt AC 1 ms 256 KB
1_008.txt AC 1 ms 256 KB
1_009.txt AC 1 ms 256 KB
1_010.txt AC 1 ms 256 KB
1_011.txt AC 2 ms 1536 KB
1_012.txt AC 2 ms 1536 KB
1_013.txt AC 2 ms 1536 KB
1_014.txt AC 288 ms 1536 KB
1_015.txt AC 288 ms 1536 KB
1_016.txt AC 288 ms 1536 KB
2_017.txt RE 98 ms 256 KB
2_018.txt RE 100 ms 256 KB
2_019.txt RE 98 ms 256 KB
2_020.txt RE 100 ms 256 KB
2_021.txt RE 99 ms 256 KB
2_022.txt RE 100 ms 256 KB
2_023.txt RE 101 ms 256 KB
2_024.txt RE 99 ms 256 KB
2_025.txt RE 99 ms 256 KB
2_026.txt RE 98 ms 256 KB
2_027.txt RE 100 ms 256 KB
2_028.txt RE 99 ms 256 KB
2_029.txt RE 99 ms 256 KB