CSES - Datatähti 2025 alku - Results
Submission details
Task:Kortit II
Sender:Pikaksi
Submission time:2024-10-29 23:54:56 +0200
Language:C++ (C++20)
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
#40
#50
Test results
testverdicttimegroup
#10.34 s1, 2, 3, 4, 5details
#20.34 s2, 3, 4, 5details
#30.34 s3, 4, 5details
#40.34 s4, 5details
#50.34 s5details
#60.34 s5details

Code

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

/*
draw possibilities:
cards
draws

location combinations of victories and draws:
    (draws)_cards

Combinations for draws not placement:
    draws!

Combinations for victory positions in list:
    (victories)_p1

Combinations for ordering p1 and p2 wins seperately wins:
    p1! * p2!

current best: binom(c; d)*binom(c; d)*d!*binom(p1+p2;p1)*p1!*p2!*binom(p1+p2;p1)
better:
binom(c; d)*binom(c; d)*d!*(p1+p2)!*3361
*/

const int C = 10;
int comparison[C];
int globalCount = 0;

bool containsNumber(int numbersUsed[C], int number)
{
    for (int i = 0; i < C; i++) {
        if (numbersUsed[i] == number) {
            return true;
        }
    }
    return false;
}

void testFunc(int numbersUsed[C])
{
        /*cout << "called with ";
        for (int i = 0; i < C; i++) {
            cout << numbersUsed[i];
        } 
        cout << "\n";*/
    bool allUsed = true;
    for (int i = 0; i < C; i++) {
        if (numbersUsed[i] == 0) {
            allUsed = false;

            for (int newNum = 1; newNum < C + 1; newNum++) {
                if (comparison[i] != newNum && !containsNumber(numbersUsed, newNum)) {
                    numbersUsed[i] = newNum;
                    testFunc(numbersUsed);
                }
            }
            numbersUsed[i] = 0;
            break;
        }
    }

    if (!allUsed) {
        return;
    }
    
    int larger = 0, smaller = 0;
    for (int i = 0; i < C; i++) {
        if (numbersUsed[i] < comparison[i]) {
            smaller++;
        }
        else if (numbersUsed[i] > comparison[i]) {
            larger++;
        }
    }
    if (smaller == 3 && larger == 7) {
        globalCount++;
    }
}

void SolveCase(int cards, int p1, int p2)
{
    int draws = cards - p1 - p2;

    string ans1;
    string ans2;

    if (p1 + p2 > cards) {
        cout << "0\n";
        return;
    }

    if ((p1 > 0 && p2 == 0) || (p2 > 0 && p1 == 0)) {
        cout << "0\n";
        return;
    }

    for (int i = cards; i > cards - draws; i--) {
        ans1 += to_string(i) + ' ';
        ans2 += to_string(i) + ' '; 
    }

    for (int i = 1; i < p1 + 1; i++) {
        ans1 += to_string(i + p2) + ' ';
        ans2 += to_string(i) + ' ';
    }

    for (int i = 1; i < p2 + 1; i++) {
        ans1 += to_string(i) + ' ';
        ans2 += to_string(i + p1) + ' ';
    }


}

int main()
{
    for (int i = 0; i < C; i++) {
        comparison[i] = i + 1;
    }
    int test[C];
    for (int i = 0; i < C; i++) {
        test[i] = 0;
    }
    testFunc(test);
    cout << globalCount;
    return 0;    
    int n;
    cin >> n;
    vector<int> input1, input2, input3;

    for (int i = 0; i < n; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        input1.push_back(a);
        input2.push_back(b);
        input3.push_back(c);
    }

    for (int i = 0; i < n; i++) {
        SolveCase(input1[i], input2[i], input3[i]);
    }
}

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
42865

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
42865

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
42865

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
42865

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
42865

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
42865