Task: | Ruudukko |
Sender: | EmuBird |
Submission time: | 2022-11-11 22:17:21 +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.04 s | 2, 3 | details |
#6 | WRONG ANSWER | 0.06 s | 2, 3 | details |
#7 | TIME LIMIT EXCEEDED | -- | 3 | details |
#8 | TIME LIMIT EXCEEDED | -- | 3 | details |
#9 | TIME LIMIT EXCEEDED | -- | 3 | details |
Compiler report
warning: unused variable: `x` --> input/code.rs:33:10 | 33 | for (x, row) in columns.iter().enumerate() { | ^ help: if this is intentional, prefix it with an underscore: `_x` | = note: `#[warn(unused_variables)]` on by default warning: unused variable: `i` --> input/code.rs:71:10 | 71 | for (i, value) in row.iter().enumerate() { | ^ help: if this is intentional, prefix it with an underscore: `_i` warning: 2 warnings emitted
Code
use std::cmp::Ordering;use std::collections::{BTreeSet, 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::<usize>().unwrap()};let mut columns: Vec<BTreeSet<(usize, Cell)>> = Vec::with_capacity(dimension);for _x in 0..dimension {columns.push(BTreeSet::new());}for _y in 0..dimension {let mut input: String = String::new();io::stdin().read_line(&mut input).unwrap();let input_row: Vec<u32> = input.split_whitespace().map(|str| str.parse::<u32>().unwrap()).collect();for (x, value) in input_row.iter().enumerate() {columns[x].insert((x, Cell {value: *value,possible_paths: calculate_reliably_until(input_row.clone(), value)}));}}let mut sum: u32 = 0;for (x, row) in columns.iter().enumerate() {let mut row_paths: HashMap<usize, u32> = HashMap::new();for (y, cell) in row {let value = cell.value;let mut path_counter = cell.possible_paths;// Horizontal matchesfor (other_x, other) in row {if other.value < value {path_counter = (path_counter + 1 + row_paths.get(other_x).unwrap_or(&0_u32)) % MOD;}}row_paths.insert(*y, path_counter);sum = (sum + path_counter) % MOD;}}println!("{}", sum);}#[derive(Eq, PartialOrd, PartialEq)]struct Cell {value: u32,possible_paths: u32,}impl Ord for Cell {fn cmp(&self, other: &Self) -> Ordering {self.value.cmp(&other.value)}}fn calculate_reliably_until(mut row: Vec<u32>, last_value: &u32) -> u32 {row.sort();let mut paths: Vec<u32> = Vec::new();let mut counter = 1;for (i, value) in row.iter().enumerate() {if value >= last_value { break; }let first_of_value = row.iter().position(|v| v == value).unwrap();let mut cell_counter = 0;for other in paths[0..first_of_value].iter() {cell_counter += 1 + other;}paths.push(cell_counter);counter += 1 + cell_counter;}counter}
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 |
---|
3 |
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 |
---|
71 |
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 |
---|
61 |
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 |
---|
100 |
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 |
---|
397846783 |
Test 6
Group: 2, 3
Verdict: WRONG ANSWER
input |
---|
100 2995 8734 1018 2513 7971 5063 ... |
correct output |
---|
964692694 |
user output |
---|
360477499 |
Test 7
Group: 3
Verdict: TIME 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) |