CSES - Datatähti 2025 alku - Results
Submission details
Task:Kortit II
Sender:alberthenriksson
Submission time:2024-10-31 15:29:06 +0200
Language:C++ (C++11)
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
#40
#50
Test results
testverdicttimegroup
#10.08 s1, 2, 3, 4, 5details
#20.08 s2, 3, 4, 5details
#30.08 s3, 4, 5details
#40.08 s4, 5details
#50.08 s5details
#60.08 s5details

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:51:37: warning: array subscript 3 is above array bounds of 'int [3]' [-Warray-bounds]
   51 |                 if (d[i][2] + d[i][3] > d[i][1]) {
      |                               ~~~~~~^
input/code.cpp:8:5: note: while referencing 'd'
    8 | int d[1050][3];
      |     ^
input/code.cpp:55:44: warning: array subscript 3 is above array bounds of 'int [3]' [-Warray-bounds]
   55 |                 if (d[i][2] == 0 and d[i][3] == 0) {
      |                                      ~~~~~~^
input/code.cpp:8:5: note: while referencing 'd'
    8 | int d[1050][3];
      |     ^
input/code.cpp:60:46: warning: array subscript 3 is above array bounds of 'int [3]' [-Warray-bounds]
   60 |                         ab = d[i][2] + d[i][3];
      |                                        ~~~~~~^
input/code.cpp:8:5: note: while referencing 'd'
    8 | int d[1050][3];
      |     ^
input/code.cpp:48:23: warning: array subscript 3 is above array bou...

Code

#include <iostream>
using namespace std;

long long p = 10000019;
long long fact[2005];
long long bino[2005][2005];
long long f[2005][2005];
int d[1050][3];
int pass = 0;
long long final;
long long ab;
long long equali;
long long val1;
long long val2;
long long val3;

int main () {
	for (int i = 0; i <= 2004; i++) {
		bino[i][0] = 1;
		bino[i][i] = 1;
	}
	for (int i = 2; i <= 2004; i++) {
		for (int j = 1; j <= i - 1; j++) {
			bino[i][j] = (bino[i - 1][j - 1] + bino[i - 1][j])%p;
		}
	}
	fact[0] = 1;
	for (int i = 1; i <= 2004; i++) {
		fact[i] = (i * fact[i - 1]) % p;
	}
	for (int i = 1; i <= 2004; i++) {
		f[i][1] = 1;
		f[i][0] = 0;
		f[i][i] = 0;
	}
	for (int i = 3; i <= 2004; i++) {
		for (int j = 2; j <= i - 1; j++) {
			f[i][j] = (j * f[i - 1][j] + (i - j) * f[i - 1][j - 1] + (i - 1) * f[i - 2][j - 1])%p;
		}
	}
	int t;
	cin >> t;
	for (int i = 1; i <= t; i++) {
		int a, b, n;
		cin >> n >> a >> b;
		d[i][1] = n;
		d[i][2] = a;
		d[i][3] = b;
	}
	for (int i = 1; i <= t; i++) {
		if (d[i][2] + d[i][3] > d[i][1]) {
			cout << 0 << "\n";
			pass = 1;
		}
		if (d[i][2] == 0 and d[i][3] == 0) {
			cout << fact[d[i][1]] << "\n";
			pass = 2;
		}
		if (pass == 0) {
			ab = d[i][2] + d[i][3];
			equali = d[i][1] - d[i][2] - d[i][3];
			val1 = (bino[d[i][1]][equali] * bino[d[i][1]][equali]) % p;
			val2 = (fact[ab] * val1) % p;
			final = (val2 * f[ab][d[i][2]]) % p;
			cout << final << "\n";
		}
		pass = 0;
	}
}

Test details

Test 1

Group: 1, 2, 3, 4, 5

Verdict:

input
54
4 4 0
3 1 3
3 2 2
4 0 4
...

correct output
0
0
0
0
0
...

user output
0
0
0
0
0
...

Test 2

Group: 2, 3, 4, 5

Verdict:

input
284
6 1 0
5 0 2
7 1 5
7 7 5
...

correct output
0
0
35280
0
36720
...

user output
0
0
35280
0
36720
...

Test 3

Group: 3, 4, 5

Verdict:

input
841
19 3 12
19 19 13
19 7 13
20 11 15
...

correct output
40291066
0
0
0
0
...

user output
1334189
0
0
0
0
...

Test 4

Group: 4, 5

Verdict:

input
1000
15 12 6
7 1 6
44 4 26
6 6 5
...

correct output
0
5040
494558320
0
340694548
...

user output
0
5040
2519
0
849059
...

Test 5

Group: 5

Verdict:

input
1000
892 638 599
966 429 655
1353 576 1140
1403 381 910
...

correct output
0
0
0
249098285
0
...

user output
0
0
0
4296414
0
...

Test 6

Group: 5

Verdict:

input
1000
2000 1107 508
2000 1372 249
2000 588 65
2000 1739 78
...

correct output
750840601
678722180
744501884
159164549
868115056
...

user output
6070284
4473499
7724806
7869742
1273845
...