Submission #22620

# Submission time Handle Problem Language Result Execution time Memory
22620 2017-04-30T05:58:59 Z ↓우리보다잘하는팀(#947, ainta, gs12117, gs13068) hi (KRIII5_HI) C++14
7 / 7
406 ms 99088 KB
#include <cstdio>

const int p = 1000000007;

int a[55], b[101], c[101], B[101], C[101];
int d[101][101], D[101][101];
int e[5005][5005];
int r[5005], R[5005];

int main() {
	int i, j, k, n;
	for (i = 1; i <= 100; i++) {
		for (j = 1; j < i; j++) {
			b[i] = (b[i] + 1ll * b[j] * c[i - j]) % p;
			B[i] = (B[i] + 1ll * b[j] * C[i - j] + 1ll * B[j] * c[i - j]) % p;
		}
		c[i] = (i - b[i] + p) % p;
		C[i] = (i * i - B[i] + p) % p;
		b[i] = (b[i] + c[i]) % p;
		B[i] = (B[i] + C[i]) % p;
	}
	d[0][0] = 1;
	for (i = 1; i <= 100; i++) for (j = 1; j <= 100; j++) for (k = 1; k <= j; k++) {
		d[i][j] = (d[i][j] + 1ll * c[k] * d[i - 1][j - k]) % p;
		D[i][j] = (D[i][j] + (i == 1 ? k == j ? C[k] : 0 : 1ll * c[k] * D[i - 1][j - k])) % p;
	}
	for (i = 0; i <= 5000; i++) {
		e[i][0] = 1;
		for (j = 1; j <= i; j++) e[i][j] = (e[i - 1][j - 1] + e[i - 1][j]) % p;
	}
	r[0] = 1;
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		for (j = 5000; j >= 0; j--) {
			r[j] = 0;
			R[j] = 0;
			for (k = 1; k <= j && k <= a[i]; k++) {
				r[j] = (r[j] + 1ll * r[j - k] * e[j][k] % p * d[k][a[i]]) % p;
				R[j] = (R[j] + 1ll * R[j - k] * d[k][a[i]] % p * e[j - 1][k] + 1ll * r[j - k] * D[k][a[i]] % p * e[j - 1][k - 1]) % p;
			}
		}
	}

	k = 0;
	for (i = 0; i <= 5000; i++) k = (k + 1ll * R[i]) % p;
	printf("%d", k);
}

Compilation message

HI.cpp: In function 'int main()':
HI.cpp:32:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
                 ^
HI.cpp:34:21: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &a[i]);
                     ^
# Verdict Execution time Memory Grader output
1 Correct 46 ms 99088 KB Output is correct
2 Correct 49 ms 99088 KB Output is correct
3 Correct 49 ms 99088 KB Output is correct
4 Correct 46 ms 99088 KB Output is correct
5 Correct 63 ms 99088 KB Output is correct
6 Correct 46 ms 99088 KB Output is correct
7 Correct 36 ms 99088 KB Output is correct
8 Correct 59 ms 99088 KB Output is correct
9 Correct 39 ms 99088 KB Output is correct
10 Correct 39 ms 99088 KB Output is correct
11 Correct 46 ms 99088 KB Output is correct
12 Correct 59 ms 99088 KB Output is correct
13 Correct 49 ms 99088 KB Output is correct
14 Correct 43 ms 99088 KB Output is correct
15 Correct 53 ms 99088 KB Output is correct
16 Correct 33 ms 99088 KB Output is correct
17 Correct 43 ms 99088 KB Output is correct
18 Correct 43 ms 99088 KB Output is correct
19 Correct 39 ms 99088 KB Output is correct
20 Correct 33 ms 99088 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 53 ms 99088 KB Output is correct
2 Correct 69 ms 99088 KB Output is correct
3 Correct 86 ms 99088 KB Output is correct
4 Correct 103 ms 99088 KB Output is correct
5 Correct 133 ms 99088 KB Output is correct
6 Correct 146 ms 99088 KB Output is correct
7 Correct 153 ms 99088 KB Output is correct
8 Correct 179 ms 99088 KB Output is correct
9 Correct 189 ms 99088 KB Output is correct
10 Correct 273 ms 99088 KB Output is correct
11 Correct 229 ms 99088 KB Output is correct
12 Correct 266 ms 99088 KB Output is correct
13 Correct 259 ms 99088 KB Output is correct
14 Correct 276 ms 99088 KB Output is correct
15 Correct 343 ms 99088 KB Output is correct
16 Correct 349 ms 99088 KB Output is correct
17 Correct 373 ms 99088 KB Output is correct
18 Correct 396 ms 99088 KB Output is correct
19 Correct 363 ms 99088 KB Output is correct
20 Correct 399 ms 99088 KB Output is correct
21 Correct 379 ms 99088 KB Output is correct
22 Correct 406 ms 99088 KB Output is correct
23 Correct 373 ms 99088 KB Output is correct
24 Correct 376 ms 99088 KB Output is correct
25 Correct 376 ms 99088 KB Output is correct
26 Correct 229 ms 99088 KB Output is correct
27 Correct 209 ms 99088 KB Output is correct
28 Correct 239 ms 99088 KB Output is correct
29 Correct 213 ms 99088 KB Output is correct
30 Correct 253 ms 99088 KB Output is correct
31 Correct 263 ms 99088 KB Output is correct
32 Correct 279 ms 99088 KB Output is correct
33 Correct 239 ms 99088 KB Output is correct
34 Correct 309 ms 99088 KB Output is correct
35 Correct 289 ms 99088 KB Output is correct
36 Correct 239 ms 99088 KB Output is correct
37 Correct 283 ms 99088 KB Output is correct
38 Correct 303 ms 99088 KB Output is correct
39 Correct 323 ms 99088 KB Output is correct
40 Correct 306 ms 99088 KB Output is correct
41 Correct 46 ms 99088 KB Output is correct
42 Correct 49 ms 99088 KB Output is correct
43 Correct 49 ms 99088 KB Output is correct
44 Correct 46 ms 99088 KB Output is correct
45 Correct 63 ms 99088 KB Output is correct
46 Correct 46 ms 99088 KB Output is correct
47 Correct 36 ms 99088 KB Output is correct
48 Correct 59 ms 99088 KB Output is correct
49 Correct 39 ms 99088 KB Output is correct
50 Correct 39 ms 99088 KB Output is correct
51 Correct 46 ms 99088 KB Output is correct
52 Correct 59 ms 99088 KB Output is correct
53 Correct 49 ms 99088 KB Output is correct
54 Correct 43 ms 99088 KB Output is correct
55 Correct 53 ms 99088 KB Output is correct
56 Correct 33 ms 99088 KB Output is correct
57 Correct 43 ms 99088 KB Output is correct
58 Correct 43 ms 99088 KB Output is correct
59 Correct 39 ms 99088 KB Output is correct
60 Correct 33 ms 99088 KB Output is correct