Task: | Kortit II |
Sender: | rottis |
Submission time: | 2024-11-05 09:36:15 +0200 |
Language: | C++ (C++17) |
Status: | READY |
Result: | 0 |
group | verdict | score |
---|---|---|
#1 | WRONG ANSWER | 0 |
#2 | WRONG ANSWER | 0 |
#3 | WRONG ANSWER | 0 |
#4 | WRONG ANSWER | 0 |
#5 | WRONG ANSWER | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | WRONG ANSWER | 0.02 s | 1, 2, 3, 4, 5 | details |
#2 | TIME LIMIT EXCEEDED | -- | 2, 3, 4, 5 | details |
#3 | TIME LIMIT EXCEEDED | -- | 3, 4, 5 | details |
#4 | TIME LIMIT EXCEEDED | -- | 4, 5 | details |
#5 | TIME LIMIT EXCEEDED | -- | 5 | details |
#6 | TIME LIMIT EXCEEDED | -- | 5 | details |
Code
#include <array> // std::array #include <iostream> int mod_by = 1000000007; int factorial(int n) { if (!n) { return 1; } int product = n; while (--n > 1) { product *= n; product %= mod_by; } return product; } int choose(int a, int b) { return (factorial(a) / (factorial(b) * factorial(a-b))); } int slow_ass_recursive_function(std::array<int, 2000> played_moves, int played_moves_size, std::array<int, 2000> moves_left, int moves_left_size, int p1_wins, int p2_wins, int p1_wins_running_total, int p2_wins_running_total) { //std::cout << "depth: " << p1_wins_running_total + p2_wins_running_total << '\n'; //std::cout << "p1 wins: " << p1_wins << ", p2_wins: " << p2_wins; //std::cout << "\np1_wins_running_total: " << p1_wins_running_total << ", p2_wins_running_total: " << p2_wins_running_total << '\n'; if (p1_wins_running_total > p1_wins || p2_wins_running_total > p2_wins) { /*std::cout << "returning 0!\n\n";*/ return 0; } if (moves_left_size == 0) { /*std::cout << "returning 1!\n\n";*/ return 1; } //std::cout << "looping!!\n\n"; int total = 0; for (int idx = 0; idx < moves_left_size; idx++) { int move = moves_left[idx]; if (move == played_moves_size-1) { continue; } //std::cout << "playing move " << move << '\n'; std::array<int, 2000> played_moves_copy = played_moves; played_moves_copy[played_moves_size-1] = move; std::array<int, 2000> moves_left_copy = moves_left; moves_left_copy[idx] = moves_left_copy[moves_left_size-1]; total += slow_ass_recursive_function(played_moves_copy, played_moves_size+1, moves_left_copy, moves_left_size-1, p1_wins, p2_wins, p1_wins_running_total + (move < played_moves_size-1), p2_wins_running_total + (move > played_moves_size-1)); total %= mod_by; } return total; } int main() { int row_count; std::cin >> row_count; while (row_count--) { int n, p1_wins, p2_wins; std::cin >> n >> p1_wins >> p2_wins; int original_n = n; int draws = n - p1_wins - p2_wins; int ways_to_choose_drawing_numbers = choose(n, draws); n -= draws; if ((p1_wins + p2_wins > 0) && (p1_wins == 0 || p2_wins == 0)) { std::cout << "0\n"; continue; } std::array<int, 2000> empty_array; std::array<int, 2000> begin_moves; for (int i = 0; i < n; i++) { begin_moves[i] = i; } //std::cout << "initial call\n"; int ways_to_choose_other_numbers = slow_ass_recursive_function( empty_array, 0, begin_moves, n, p1_wins, p2_wins, 0, 0 ); //std::cout << "1: " << ways_to_choose_drawing_numbers << ", 2: " << ways_to_choose_other_numbers << ", 3: " << factorial(original_n) << std::endl; std::cout << (((ways_to_choose_drawing_numbers * ways_to_choose_other_numbers) % mod_by) * factorial(original_n)) % (mod_by) << '\n'; } std::cout.flush(); return 0; }
Test details
Test 1
Group: 1, 2, 3, 4, 5
Verdict: WRONG ANSWER
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: TIME LIMIT EXCEEDED
input |
---|
284 6 1 0 5 0 2 7 1 5 7 7 5 ... |
correct output |
---|
0 0 35280 0 36720 ... |
user output |
---|
(empty) |
Test 3
Group: 3, 4, 5
Verdict: TIME LIMIT EXCEEDED
input |
---|
841 19 3 12 19 19 13 19 7 13 20 11 15 ... |
correct output |
---|
40291066 0 0 0 0 ... |
user output |
---|
(empty) |
Test 4
Group: 4, 5
Verdict: TIME LIMIT EXCEEDED
input |
---|
1000 15 12 6 7 1 6 44 4 26 6 6 5 ... |
correct output |
---|
0 5040 494558320 0 340694548 ... |
user output |
---|
(empty) |
Test 5
Group: 5
Verdict: TIME LIMIT EXCEEDED
input |
---|
1000 892 638 599 966 429 655 1353 576 1140 1403 381 910 ... |
correct output |
---|
0 0 0 249098285 0 ... |
user output |
---|
(empty) |
Test 6
Group: 5
Verdict: TIME LIMIT EXCEEDED
input |
---|
1000 2000 1107 508 2000 1372 249 2000 588 65 2000 1739 78 ... |
correct output |
---|
750840601 678722180 744501884 159164549 868115056 ... |
user output |
---|
(empty) |