Submission #20948922


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

bool win(vector<int> S, vector<int> T){
    vector<int> count(9, 0);
    for (auto s: S) {
        count[s - 1]++;
    }
    int score_s = 0;
    for (int i = 0; i < 9; i++) {
        if (count[i] == 0) continue;
        score_s += (i + 1) * pow(10, count[i]);
    }

    vector<int> count_t(9, 0);
    for (auto t: T) {
        count_t[t - 1]++;
    }
    int score_t = 0;
    for (int i = 0; i < 9; i++) {
        if (count_t[i] == 0) continue;
        score_t += (i + 1) * pow(10, count_t[i]);
    }

    return score_s > score_t;
}


int main() {
    int K;
    string S, T;
    cin >> K;
    cin >> S >> T;

    vector <int> si, ti;
    for (auto s: S) {
        if (s == '#') break;
        si.push_back(s - '0');
    }
    for (auto t: T) {
        if (t == '#') break;
        ti.push_back(t - '0');
    }
    
    vector<int> tot_num(9, K);
    for (auto s: si) {
        tot_num[s - 1]--;
    }
    for (auto t: ti) {
        tot_num[t - 1]--;
    }

    double win_case = 0, lose_case = 0;
    for (int s = 1; s <= 9; s++) {
        for (int t = 1; t <= 9; t++) {
            si.push_back(s);
            ti.push_back(t);

            int num_case = 0;
            if (s == t) {
                num_case = tot_num[s - 1] * (tot_num[s - 1] - 1);
            } else {
                num_case = tot_num[s - 1] * tot_num[t - 1];
            }

            if (win(si, ti) == true) {win_case += num_case;} 
            else {lose_case += num_case;}
            si.pop_back();
            ti.pop_back();            
        }
    }
    double ans = win_case * 1.0L / (win_case + lose_case);

    printf("%f6\n", ans);

}

/*
6
1122#
2228#
*/

Submission Info

Submission Time
Task D - Poker
User amanou
Language C++ (GCC 9.2.1)
Score 0
Code Size 1800 Byte
Status WA
Exec Time 3 ms
Memory 4232 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 400
Status
AC × 3
WA × 1
AC × 28
WA × 8
Set Name Test Cases
Sample 01_sample.txt, 02_sample.txt, 03_sample.txt, 04_sample.txt
All 01_sample.txt, 02_sample.txt, 03_sample.txt, 04_sample.txt, 05_hand.txt, 06_hand.txt, 07_random1.txt, 08_random1.txt, 09_random1.txt, 10_random1.txt, 11_random1.txt, 12_random1.txt, 13_random1.txt, 14_random2.txt, 15_random2.txt, 16_random2.txt, 17_random2.txt, 18_random2.txt, 19_random2.txt, 20_random2.txt, 21_random2.txt, 22_random2.txt, 23_random2.txt, 24_random3.txt, 25_random3.txt, 26_random3.txt, 27_random3.txt, 28_random3.txt, 29_random3.txt, 30_random3.txt, 31_random3.txt, 32_random3.txt, 33_random4.txt, 34_random4.txt, 35_random4.txt, 36_random4.txt
Case Name Status Exec Time Memory
01_sample.txt AC 2 ms 4088 KiB
02_sample.txt AC 2 ms 3924 KiB
03_sample.txt AC 2 ms 4104 KiB
04_sample.txt WA 2 ms 3960 KiB
05_hand.txt AC 2 ms 4040 KiB
06_hand.txt AC 2 ms 4148 KiB
07_random1.txt WA 2 ms 3828 KiB
08_random1.txt WA 2 ms 3704 KiB
09_random1.txt AC 1 ms 3628 KiB
10_random1.txt AC 2 ms 3912 KiB
11_random1.txt AC 2 ms 3624 KiB
12_random1.txt WA 2 ms 3832 KiB
13_random1.txt AC 1 ms 3888 KiB
14_random2.txt AC 2 ms 4232 KiB
15_random2.txt AC 2 ms 3908 KiB
16_random2.txt AC 1 ms 4016 KiB
17_random2.txt AC 3 ms 4064 KiB
18_random2.txt AC 2 ms 3812 KiB
19_random2.txt WA 3 ms 3920 KiB
20_random2.txt AC 2 ms 4080 KiB
21_random2.txt AC 2 ms 4064 KiB
22_random2.txt AC 3 ms 3876 KiB
23_random2.txt AC 3 ms 3880 KiB
24_random3.txt AC 2 ms 4216 KiB
25_random3.txt WA 2 ms 3728 KiB
26_random3.txt AC 2 ms 3788 KiB
27_random3.txt AC 2 ms 4076 KiB
28_random3.txt AC 2 ms 4068 KiB
29_random3.txt WA 2 ms 3980 KiB
30_random3.txt AC 2 ms 3976 KiB
31_random3.txt AC 3 ms 3980 KiB
32_random3.txt AC 2 ms 3924 KiB
33_random4.txt AC 2 ms 3988 KiB
34_random4.txt AC 2 ms 3984 KiB
35_random4.txt WA 2 ms 4044 KiB
36_random4.txt AC 2 ms 3924 KiB