CSES - Datatähti 2020 alku - Results
Submission details
Task:Ruudukko
Sender:aleksih
Submission time:2019-10-02 13:11:47 +0300
Language:Rust
Status:READY
Result:100
Feedback
groupverdictscore
#1ACCEPTED100
Test results
testverdicttime
#1ACCEPTED0.01 sdetails
#2ACCEPTED0.01 sdetails
#3ACCEPTED0.01 sdetails
#4ACCEPTED0.01 sdetails
#5ACCEPTED0.03 sdetails
#6ACCEPTED0.03 sdetails

Compiler report

warning: unused variable: `i`
  --> input/code.rs:11:9
   |
11 |     for i in 0..koko {
   |         ^ help: consider prefixing with an underscore: `_i`
   |
   = note: #[warn(unused_variables)] on by default

warning: unused variable: `j`
  --> input/code.rs:13:13
   |
13 |         for j in 0..koko {
   |             ^ help: consider prefixing with an underscore: `_j`

warning: unused variable: `riv_pienin_sallittu`
  --> input/code.rs:20:17
   |
20 |         let mut riv_pienin_sallittu = 1;
   |                 ^^^^^^^^^^^^^^^^^^^ help: consider prefixing with an underscore: `_riv_pienin_sallittu`

warning: variable does not need to be mutable
  --> input/code.rs:20:13
   |
20 |         let mut riv_pienin_sallittu = 1;
   |             ----^^^^^^^^^^^^^^^^^^^
   |             |
   |             help: remove this `mut`
   |
   = note: #[warn(unused_mut)] on by default

Code

use std::io;

fn main() {
    let mut koko_str = String::new();
    io::stdin()
        .read_line(&mut koko_str).unwrap();

    let koko = koko_str
        .trim().parse::<usize>().unwrap();
    let mut ruudukko = Vec::with_capacity(koko);
    for i in 0..koko {
        let mut sar = Vec::with_capacity(koko);
        for j in 0..koko {
            sar.push(0);
        }
        ruudukko.push(sar);
    }
    
    for i in 0..koko {
        let mut riv_pienin_sallittu = 1;
        for j in 0..koko {
            let mut sar = Vec::with_capacity(koko);
            for k in 0..koko {
                sar.push(ruudukko[k][j]);
            }

            let mut arvaus = 1;
            while sar.contains(&arvaus) || ruudukko[i].contains(&arvaus) {
                arvaus += 1;
            }

            ruudukko[i][j] = arvaus;
        }
    }

    for i in 0..koko {
        for j in 0..koko {
            print!("{}", ruudukko[i][j]);
            if j != koko - 1 {
                print!(" ");
            }
        }
        println!("");
    }
}

Test details

Test 1

Verdict: ACCEPTED

input
1

correct output

user output
1

Test 2

Verdict: ACCEPTED

input
2

correct output
1 2 
2 1 

user output
1 2
2 1

Test 3

Verdict: ACCEPTED

input
5

correct output
1 2 3 4 5 
2 1 4 3 6 
3 4 1 2 7 
4 3 2 1 8 
5 6 7 8 1 

user output
1 2 3 4 5
2 1 4 3 6
3 4 1 2 7
4 3 2 1 8
5 6 7 8 1

Test 4

Verdict: ACCEPTED

input
42

correct output
1 2 3 4 5 6 7 8 9 10 11 12 13 ...

user output
1 2 3 4 5 6 7 8 9 10 11 12 13 ...
Truncated

Test 5

Verdict: ACCEPTED

input
99

correct output
1 2 3 4 5 6 7 8 9 10 11 12 13 ...

user output
1 2 3 4 5 6 7 8 9 10 11 12 13 ...
Truncated

Test 6

Verdict: ACCEPTED

input
100

correct output
1 2 3 4 5 6 7 8 9 10 11 12 13 ...

user output
1 2 3 4 5 6 7 8 9 10 11 12 13 ...
Truncated