Submission #20544976


Source Code Expand

use proconio::{fastout, input};

fn get_value(hands: [i32; 10]) -> i64 {
    let mut value = 0;

    for i in 1..=9 {
        let mut v = i as i64;
        for _ in 1..=hands[i] {
            v *= 10;
        }
        value += v;
    }

    return value;
}

#[fastout]
fn main() {
    input! {in_k: i64, in_s: String, in_t: String};
    let mut hands1 = [0; 10];
    let mut hands2 = [0; 10];
    let mut cards = [in_k; 10];
    let mut wincount = 0;

    for i in 0..4 {
        let h1 = in_s.chars().nth(i).unwrap() as usize - 48;
        let h2 = in_t.chars().nth(i).unwrap() as usize - 48;

        hands1[h1] += 1;
        hands2[h2] += 1;
        cards[h1] -= 1;
        cards[h2] -= 1;
    }

    eprintln!("{:?}", hands1);
    eprintln!("{:?}", hands2);
    eprintln!("{:?}", cards);

    for i in 1..=9 {
        if cards[i] == 0 {
            continue;
        }

        let w1 = cards[i];
        cards[i] -= 1;
        hands1[i] += 1;
        let v1 = get_value(hands1);

        for j in 1..=9 {
            if cards[j] == 0 {
                continue;
            }

            let w2 = cards[j];
            hands2[j] += 1;
            let v2 = get_value(hands2);
            hands2[j] -= 1;
            if v1 > v2 {
                eprintln!("{:?} - {:?} -> {} - {}", hands1, hands2, v1, v2);
                wincount += w1 * w2;
            }
        }

        cards[i] += 1;
        hands1[i] -= 1;
    }

    eprintln!("{} {}", wincount, (9 * in_k - 8) * (9 * in_k - 9));
    println!(
        "{:.6}",
        wincount as f32 / ((9 * in_k - 8) * (9 * in_k - 9)) as f32
    );
}

Submission Info

Submission Time
Task D - Poker
User takedarts
Language Rust (1.42.0)
Score 400
Code Size 1602 Byte
Status AC
Exec Time 16 ms
Memory 2236 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 4
AC × 36
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 7 ms 2180 KiB
02_sample.txt AC 7 ms 2236 KiB
03_sample.txt AC 2 ms 2180 KiB
04_sample.txt AC 9 ms 2064 KiB
05_hand.txt AC 2 ms 2072 KiB
06_hand.txt AC 14 ms 2040 KiB
07_random1.txt AC 10 ms 2172 KiB
08_random1.txt AC 13 ms 2096 KiB
09_random1.txt AC 10 ms 2140 KiB
10_random1.txt AC 11 ms 2108 KiB
11_random1.txt AC 7 ms 2108 KiB
12_random1.txt AC 4 ms 2164 KiB
13_random1.txt AC 8 ms 2140 KiB
14_random2.txt AC 3 ms 2132 KiB
15_random2.txt AC 3 ms 2024 KiB
16_random2.txt AC 2 ms 2120 KiB
17_random2.txt AC 4 ms 2164 KiB
18_random2.txt AC 7 ms 2020 KiB
19_random2.txt AC 8 ms 2164 KiB
20_random2.txt AC 6 ms 2116 KiB
21_random2.txt AC 3 ms 2072 KiB
22_random2.txt AC 2 ms 2136 KiB
23_random2.txt AC 7 ms 2024 KiB
24_random3.txt AC 10 ms 2064 KiB
25_random3.txt AC 3 ms 2044 KiB
26_random3.txt AC 3 ms 2128 KiB
27_random3.txt AC 16 ms 2116 KiB
28_random3.txt AC 6 ms 2204 KiB
29_random3.txt AC 12 ms 2128 KiB
30_random3.txt AC 2 ms 2008 KiB
31_random3.txt AC 7 ms 2016 KiB
32_random3.txt AC 4 ms 2108 KiB
33_random4.txt AC 6 ms 2132 KiB
34_random4.txt AC 10 ms 2104 KiB
35_random4.txt AC 13 ms 2148 KiB
36_random4.txt AC 10 ms 2108 KiB