CSES - Datatähti 2025 alku - Results
Submission details
Task:Kortit II
Sender:Onni
Submission time:2024-11-01 22:42:49 +0200
Language:Rust (2021)
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
#40
#50
Test results
testverdicttimegroup
#10.00 s1, 2, 3, 4, 5details
#20.00 s2, 3, 4, 5details
#30.01 s3, 4, 5details
#40.01 s4, 5details
#50.10 s5details
#60.42 s5details

Compiler report

warning: unused variable: `i`
  --> input/code.rs:48:21
   |
48 |                 for i in 0..player_2_score {
   |                     ^ help: if this is intentional, prefix it with an underscore: `_i`
   |
   = note: `#[warn(unused_variables)]` on by default

warning: unused variable: `i`
  --> input/code.rs:56:21
   |
56 |                 for i in 0..player_1_score {
   |                     ^ help: if this is intentional, prefix it with an underscore: `_i`

warning: 2 warnings emitted

Code

use std::io;

fn main() {
    let mut game_data: Vec<Vec<i32>> = Vec::new();

    let mut input_test_count = String::new();
    io::stdin().read_line(&mut input_test_count).expect("Failed to read line");
    let test_count: usize = input_test_count.trim().parse().expect("Not a number");

    for _ in 0..test_count {
        let mut input_game_data = String::new();
        io::stdin().read_line(&mut input_game_data).expect("Failed to read line");
        let input_values: Vec<i32> = input_game_data
            .trim()
            .split_whitespace()
            .filter_map(|value| value.parse::<i32>().ok())
            .collect();
        game_data.push(input_values);
    }

    for i in 0..game_data.len() {
        let input_numbers = game_data[i][0];
        let player_1_score = game_data[i][1];
        let player_2_score = game_data[i][2];

        if (player_1_score == 0 || player_2_score == 0) && player_1_score + player_2_score != 0 {
            println!("NO");
        } else if player_1_score + player_2_score > input_numbers {
            println!("NO");
        } else {
            println!("YES");

            let available_cards: Vec<i32> = (1..=input_numbers).collect();
            let mut player_1_played_cards: Vec<i32> = Vec::new();
            let mut player_2_played_cards: Vec<i32> = Vec::new();

            let draw_games = input_numbers - player_1_score - player_2_score;
            let mut player_1_cards = available_cards.clone();
            let mut player_2_cards = available_cards.clone();

            for _ in 0..draw_games {
                player_1_played_cards.push(player_1_cards.pop().unwrap());
                player_2_played_cards.push(player_2_cards.pop().unwrap());
            }

            if player_1_score > player_2_score {
                player_2_played_cards.extend(player_2_cards);
                for i in 0..player_2_score {
                    let temp = player_1_cards[0];
                    player_1_cards.remove(0);
                    player_1_cards.push(temp);
                }
                player_1_played_cards.extend(player_1_cards);
            } else if player_1_score < player_2_score {
                player_1_played_cards.extend(player_1_cards);
                for i in 0..player_1_score {
                    let temp = player_2_cards[0];
                    player_2_cards.remove(0);
                    player_2_cards.push(temp);
                }
                player_2_played_cards.extend(player_2_cards);
            } else {
                player_2_cards.reverse();
                player_1_played_cards.extend(player_1_cards);
                player_2_played_cards.extend(player_2_cards);
            }

            for i in 0..player_1_played_cards.len() {
                print!("{:?} ", player_1_played_cards[i as usize]);
            }

            println!();

            for i in 0..player_2_played_cards.len() {
                print!("{:?} ", player_2_played_cards[i as usize]);
            }

            println!();
        }
    }
}

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
NO
NO
NO
NO
NO
...

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
NO
NO
YES
7 1 2 3 4 5 6 
7 2 3 4 5 6 1 
...

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
YES
19 18 17 16 1 2 3 4 5 6 7 8 9 ...

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
NO
YES
1 2 3 4 5 6 7 
2 3 4 5 6 7 1 
YES
...

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
NO
NO
NO
YES
1403 1402 1401 1400 1399 1398 ...

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
YES
2000 1999 1998 1997 1996 1995 ...