| Task: | Ruudukko | 
| Sender: | EmuBird | 
| Submission time: | 2022-11-06 20:47:25 +0200 | 
| Language: | Rust | 
| Status: | READY | 
| Result: | 0 | 
| group | verdict | score | 
|---|---|---|
| #1 | WRONG ANSWER | 0 | 
| #2 | WRONG ANSWER | 0 | 
| #3 | WRONG ANSWER | 0 | 
| test | verdict | time | group | |
|---|---|---|---|---|
| #1 | WRONG ANSWER | 0.00 s | 1, 2, 3 | details | 
| #2 | WRONG ANSWER | 0.00 s | 1, 2, 3 | details | 
| #3 | WRONG ANSWER | 0.00 s | 1, 2, 3 | details | 
| #4 | WRONG ANSWER | 0.01 s | 2, 3 | details | 
| #5 | WRONG ANSWER | 0.02 s | 2, 3 | details | 
| #6 | WRONG ANSWER | 0.02 s | 2, 3 | details | 
| #7 | OUTPUT LIMIT EXCEEDED | 0.00 s | 3 | details | 
| #8 | TIME LIMIT EXCEEDED | -- | 3 | details | 
| #9 | TIME LIMIT EXCEEDED | -- | 3 | details | 
Compiler report
warning: unused variable: `last_value` --> input/code.rs:44:9 | 44 | let last_value = values_sorted.last().unwrap(); | ^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_last_value` | = note: `#[warn(unused_variables)]` on by default warning: 1 warning emitted
Code
use std::collections::hash_map::Entry;
use std::collections::HashMap;
use std::io;
const MOD: u32 = (10_i32.pow(9) + 7) as u32;
fn main() {
    let dimension = {
        let mut input: String = String::new();
        io::stdin().read_line(&mut input).unwrap();
        input.strip_suffix("\n").unwrap().parse::<u16>().unwrap()
    };
    let mut rows: Vec<Vec<Cell>> = Vec::with_capacity(dimension as usize);
    let mut coordinates_by_value: HashMap<u32, Vec<(u16, u16)>> = HashMap::new();
    for y in 0..dimension {
        let mut input: String = String::new();
        io::stdin().read_line(&mut input).unwrap();
        let mut row: Vec<Cell> = Vec::with_capacity(dimension as usize);
        let mut x: u16 = 0;
        for str in input.split_whitespace() {
            let value = str.parse::<u32>().unwrap();
            row.push(Cell {
                value,
                possible_paths: 0
            });
            match coordinates_by_value.entry(value) {
                Entry::Occupied(entry) => { entry.into_mut().push((y, x)); }
                Entry::Vacant(entry) => { entry.insert(vec![(y, x)]); }
            }
            x += 1;
        }
        rows.push(row);
    }
    let mut values_sorted = coordinates_by_value.keys().collect::<Vec<&u32>>();
    values_sorted.sort();
    let last_value = values_sorted.last().unwrap();
    let mut sum: u32 = 0;
    for value in &values_sorted {
        if **value <= 1 { continue; }
        for (y, x) in &coordinates_by_value[value] {
            let x = *x as usize;
            let y = *y as usize;
            let mut path_counter = 0;
            // Vertical matches
            for (yi, row) in rows.iter().enumerate() {
                if yi == y { continue; }
                let cell = row.get(x).unwrap();
                if cell.value < **value {
                    path_counter = (path_counter + 1 + cell.possible_paths) % MOD;
                }
            }
            // Horizontal matches
            let column = rows.get(y).unwrap();
            for (xi, cell) in column.iter().enumerate() {
                if xi == x { continue; }
                if cell.value < **value {
                    path_counter = (path_counter + 1 + cell.possible_paths) % MOD;
                }
            }
            rows.get_mut(y).unwrap().get_mut(x).unwrap().possible_paths = path_counter;
            sum = (sum + path_counter) % MOD;
        }
    }
    println!("{:?}", rows);
    println!("{}", sum);
}
#[derive(Debug)]
struct Cell {
    value: u32,
    possible_paths: u32,
}
Test details
Test 1
Group: 1, 2, 3
Verdict: WRONG ANSWER
| input | 
|---|
| 3 1 1 1 1 1 1 1 1 1  | 
| correct output | 
|---|
| 9 | 
| user output | 
|---|
| [[Cell { value: 1, possible_pa... Truncated  | 
Test 2
Group: 1, 2, 3
Verdict: WRONG ANSWER
| input | 
|---|
| 3 1 2 3 6 5 4 7 8 9  | 
| correct output | 
|---|
| 135 | 
| user output | 
|---|
| [[Cell { value: 1, possible_pa... Truncated  | 
Test 3
Group: 1, 2, 3
Verdict: WRONG ANSWER
| input | 
|---|
| 3 7 8 1 4 5 4 3 9 6  | 
| correct output | 
|---|
| 57 | 
| user output | 
|---|
| [[Cell { value: 7, possible_pa... Truncated  | 
Test 4
Group: 2, 3
Verdict: WRONG ANSWER
| input | 
|---|
| 100 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...  | 
| correct output | 
|---|
| 10000 | 
| user output | 
|---|
| [[Cell { value: 1, possible_pa... Truncated  | 
Test 5
Group: 2, 3
Verdict: WRONG ANSWER
| input | 
|---|
| 100 1 2 3 4 5 6 7 8 9 10 11 12 13 ...  | 
| correct output | 
|---|
| 187458477 | 
| user output | 
|---|
| [[Cell { value: 1, possible_pa... Truncated  | 
Test 6
Group: 2, 3
Verdict: WRONG ANSWER
| input | 
|---|
| 100 2995 8734 1018 2513 7971 5063 ...  | 
| correct output | 
|---|
| 964692694 | 
| user output | 
|---|
| [[Cell { value: 2995, possible... Truncated  | 
Test 7
Group: 3
Verdict: OUTPUT LIMIT EXCEEDED
| input | 
|---|
| 1000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...  | 
| correct output | 
|---|
| 1000000 | 
| user output | 
|---|
| (empty) | 
Test 8
Group: 3
Verdict: TIME LIMIT EXCEEDED
| input | 
|---|
| 1000 1 2 3 4 5 6 7 8 9 10 11 12 13 ...  | 
| correct output | 
|---|
| 229147081 | 
| user output | 
|---|
| (empty) | 
Test 9
Group: 3
Verdict: TIME LIMIT EXCEEDED
| input | 
|---|
| 1000 520283 805991 492643 75254 527...  | 
| correct output | 
|---|
| 951147313 | 
| user output | 
|---|
| (empty) | 
