CSES - Putka Open 2020 – 2/5 - Results
Submission details
Task:Planeetat
Sender:Olli
Submission time:2020-09-27 23:29:23 +0300
Language:C++ (C++11)
Status:READY
Result:100
Feedback
groupverdictscore
#1ACCEPTED24
#2ACCEPTED25
#3ACCEPTED51
Test results
testverdicttimegroup
#1ACCEPTED0.57 s1, 2, 3details
#2ACCEPTED0.57 s1, 2, 3details
#3ACCEPTED0.57 s1, 2, 3details
#4ACCEPTED0.57 s1, 2, 3details
#5ACCEPTED0.57 s1, 2, 3details
#6ACCEPTED0.56 s1, 2, 3details
#7ACCEPTED0.57 s1, 2, 3details
#8ACCEPTED0.57 s1, 2, 3details
#9ACCEPTED0.57 s1, 2, 3details
#10ACCEPTED0.57 s1, 2, 3details
#11ACCEPTED0.57 s2, 3details
#12ACCEPTED0.57 s2, 3details
#13ACCEPTED0.57 s2, 3details
#14ACCEPTED0.57 s3details
#15ACCEPTED0.67 s3details
#16ACCEPTED0.80 s3details
#17ACCEPTED0.80 s3details
#18ACCEPTED0.80 s3details
#19ACCEPTED0.82 s3details
#20ACCEPTED0.80 s3details
#21ACCEPTED0.80 s3details
#22ACCEPTED0.82 s3details
#23ACCEPTED0.80 s3details
#24ACCEPTED0.81 s3details
#25ACCEPTED0.81 s3details

Code

#include <iostream>
 
using namespace std;
 
typedef long long ll;
 
const int M = 1e9 + 7;
const int N = 5e3 + 5;
 
ll ans[N][N]; //ans[x][y] tells how many ways there is to divide x into y components
ll b[N][N]; //b[n][k] = (n choose k)
ll fa[N];
 
ll f[N][N]; //Adjoin x more, when there are k ready
 
ll exp(ll a, ll e) {
	if(e == 0) return 1;
	if(e%2 == 0) {
		ll b = exp(a, e/2);
		return (b*b)%M;
	}
	ll b = exp(a, e-1);
	return (a*b)%M;
}

ll cyc[N][N];
 
int main() {
	fa[0] = 1;
	for(ll i = 1; i < N; ++i) {
		fa[i] = fa[i-1]*i;
		fa[i] %= M;
	}
	for(int i = 0; i < N; ++i) {
		b[i][0] = 1;
		b[i][i] = 1;
	}
	for(int i = 1; i < N; ++i) {
		for(int j = 1; j < i; ++j) {
			b[i][j] = b[i-1][j-1] + b[i-1][j];
			b[i][j] %= M;
		}
	}
 
	for(int k = 0; k < N; ++k) {
		f[0][k] = 1;
	}

	for(int s = 2; s < 2*N; ++s) {
		ll c = 1;
		for(ll x = 1; x < N; ++x) {
			ll k = s - x;
			if(k >= N) continue;
			f[x][k] = (k*c)%M;
			c *= s;
			c %= M;
		}
	}


	for(ll a = 1; a < N; ++a) {
		cyc[a][1] = fa[a-1];
		for(ll c = 2; c <= a; ++c) {
			cyc[a][c] = cyc[a-1][c-1] + (a-1)*cyc[a-1][c];
			cyc[a][c] %= M;
		}
	}

	int n;
	cin >> n;
	for(int c = 1; c <= n; ++c) {
		ll ans = 0;
		for(int a = c; a <= n; ++a) {
			ll cur = b[n][a];
			cur *= cyc[a][c];
			cur %= M;
			cur *= f[n-a][a];
			ans += cur;
			ans %= M;
		}
		cout << ans << " ";
	}
	cout << "\n";
 
}

Test details

Test 1

Group: 1, 2, 3

Verdict: ACCEPTED

input
1

correct output
1

user output

Test 2

Group: 1, 2, 3

Verdict: ACCEPTED

input
2

correct output
3
1

user output
3 1 

Test 3

Group: 1, 2, 3

Verdict: ACCEPTED

input
3

correct output
17
9
1

user output
17 9 1 

Test 4

Group: 1, 2, 3

Verdict: ACCEPTED

input
4

correct output
142
95
18
1

user output
142 95 18 1 

Test 5

Group: 1, 2, 3

Verdict: ACCEPTED

input
5

correct output
1569
1220
305
30
1

user output
1569 1220 305 30 1 

Test 6

Group: 1, 2, 3

Verdict: ACCEPTED

input
6

correct output
21576
18694
5595
745
45
...

user output
21576 18694 5595 745 45 1 

Test 7

Group: 1, 2, 3

Verdict: ACCEPTED

input
7

correct output
355081
334369
113974
18515
1540
...

user output
355081 334369 113974 18515 154...

Test 8

Group: 1, 2, 3

Verdict: ACCEPTED

input
8

correct output
6805296
6852460
2581964
484729
49840
...

user output
6805296 6852460 2581964 484729...

Test 9

Group: 1, 2, 3

Verdict: ACCEPTED

input
9

correct output
148869153
158479488
64727522
13591116
1632099
...

user output
148869153 158479488 64727522 1...

Test 10

Group: 1, 2, 3

Verdict: ACCEPTED

input
10

correct output
660215659
85349908
783995053
409987640
55545735
...

user output
660215659 85349908 783995053 4...

Test 11

Group: 2, 3

Verdict: ACCEPTED

input
20

correct output
8033007
474885151
998010619
720259168
345757330
...

user output
8033007 474885151 998010619 72...
Truncated

Test 12

Group: 2, 3

Verdict: ACCEPTED

input
50

correct output
637699856
613177596
194234103
50828885
988168359
...

user output
637699856 613177596 194234103 ...
Truncated

Test 13

Group: 2, 3

Verdict: ACCEPTED

input
100

correct output
894456323
406549429
962038245
430640330
61348310
...

user output
894456323 406549429 962038245 ...
Truncated

Test 14

Group: 3

Verdict: ACCEPTED

input
666

correct output
189730587
968711879
553374698
53051125
139917248
...

user output
189730587 968711879 553374698 ...
Truncated

Test 15

Group: 3

Verdict: ACCEPTED

input
3333

correct output
79235821
455292218
627100211
591681254
695866885
...

user output
79235821 455292218 627100211 5...
Truncated

Test 16

Group: 3

Verdict: ACCEPTED

input
4991

correct output
482116496
245260697
151422537
180441123
318466624
...

user output
482116496 245260697 151422537 ...
Truncated

Test 17

Group: 3

Verdict: ACCEPTED

input
4992

correct output
141010647
787351178
684701591
872974815
631476284
...

user output
141010647 787351178 684701591 ...
Truncated

Test 18

Group: 3

Verdict: ACCEPTED

input
4993

correct output
504034249
588971460
281533415
928250892
416697844
...

user output
504034249 588971460 281533415 ...
Truncated

Test 19

Group: 3

Verdict: ACCEPTED

input
4994

correct output
266134603
90079109
544661648
812099750
17249410
...

user output
266134603 90079109 544661648 8...
Truncated

Test 20

Group: 3

Verdict: ACCEPTED

input
4995

correct output
833898560
663839791
109127071
321675160
86285359
...

user output
833898560 663839791 109127071 ...
Truncated

Test 21

Group: 3

Verdict: ACCEPTED

input
4996

correct output
721158645
167929822
115103278
491345159
114397872
...

user output
721158645 167929822 115103278 ...
Truncated

Test 22

Group: 3

Verdict: ACCEPTED

input
4997

correct output
691405606
436947443
82656395
514529009
783319673
...

user output
691405606 436947443 82656395 5...
Truncated

Test 23

Group: 3

Verdict: ACCEPTED

input
4998

correct output
829675470
688714502
189351950
956110193
20883331
...

user output
829675470 688714502 189351950 ...
Truncated

Test 24

Group: 3

Verdict: ACCEPTED

input
4999

correct output
343936737
47032567
190931571
827280581
160866637
...

user output
343936737 47032567 190931571 8...
Truncated

Test 25

Group: 3

Verdict: ACCEPTED

input
5000

correct output
364064601
633559852
352848841
666954216
428009512
...

user output
364064601 633559852 352848841 ...
Truncated