Submission #1188032


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 mod_pow(ll x, ll n, ll mod) {
	if (n == 0) return 1;
	ll res = mod_pow(x * x % mod, n / 2, mod);
	if (n & 1) res = res * x % mod;
	return res;
}

ll dfs(int pos, int cnt) {
	if (pos == n) return cnt == c;
	if (~dp[pos][cnt]) return dp[pos][cnt];
	
	ll res = 0;
	
	REP(i, c - cnt + 1) (res += dfs(pos + 1, cnt + i) * mod_pow(a[pos], i, MOD) % MOD) % 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 0
Code Size 1282 Byte
Status RE
Exec Time 4203 ms
Memory 1536 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:45: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:46: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 0 / 400 0 / 400
Status
AC × 2
RE × 3
AC × 9
TLE × 3
AC × 11
TLE × 3
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 100 ms 256 KB
0_001.txt AC 1 ms 256 KB
0_002.txt RE 98 ms 256 KB
0_003.txt AC 1 ms 256 KB
0_004.txt RE 99 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 TLE 4203 ms 1536 KB
1_015.txt TLE 4203 ms 1536 KB
1_016.txt TLE 4203 ms 1536 KB
2_017.txt RE 100 ms 256 KB
2_018.txt RE 100 ms 256 KB
2_019.txt RE 98 ms 256 KB
2_020.txt RE 98 ms 256 KB
2_021.txt RE 99 ms 256 KB
2_022.txt RE 99 ms 256 KB
2_023.txt RE 97 ms 256 KB
2_024.txt RE 101 ms 256 KB
2_025.txt RE 100 ms 256 KB
2_026.txt RE 98 ms 256 KB
2_027.txt RE 98 ms 256 KB
2_028.txt RE 98 ms 256 KB
2_029.txt RE 98 ms 256 KB