結果
問題 | No.2157 崖 |
ユーザー | nephrologist |
提出日時 | 2022-12-16 14:24:35 |
言語 | Rust (1.77.0 + proconio) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,394 bytes |
コンパイル時間 | 13,247 ms |
コンパイル使用メモリ | 378,352 KB |
実行使用メモリ | 94,080 KB |
最終ジャッジ日時 | 2024-11-15 19:42:23 |
合計ジャッジ時間 | 21,507 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
5,248 KB |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | RE | - |
testcase_04 | AC | 1 ms
5,248 KB |
testcase_05 | RE | - |
testcase_06 | RE | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | AC | 1 ms
5,248 KB |
testcase_10 | AC | 1 ms
5,248 KB |
testcase_11 | RE | - |
testcase_12 | AC | 1 ms
5,248 KB |
testcase_13 | WA | - |
testcase_14 | RE | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | RE | - |
testcase_18 | RE | - |
testcase_19 | WA | - |
testcase_20 | RE | - |
testcase_21 | RE | - |
testcase_22 | RE | - |
testcase_23 | AC | 1 ms
5,248 KB |
testcase_24 | RE | - |
コンパイルメッセージ
warning: variable does not need to be mutable --> src/main.rs:8:13 | 8 | let mut s = { | ----^ | | | help: remove this `mut` ... 52 | input!(n: usize, m: usize, D: [[i128; m]; n]); | --------------------------------------------- in this macro invocation | = note: `#[warn(unused_mut)]` on by default = note: this warning originates in the macro `input` (in Nightly builds, run with -Z macro-backtrace for more info) warning: unused variable: `j` --> src/main.rs:119:13 | 119 | for j in 0..m { | ^ help: if this is intentional, prefix it with an underscore: `_j` | = note: `#[warn(unused_variables)]` on by default warning: variable `D` should have a snake case name --> src/main.rs:52:32 | 52 | input!(n: usize, m: usize, D: [[i128; m]; n]); | ^ help: convert the identifier to snake case: `d` | = note: `#[warn(non_snake_case)]` on by default
ソースコード
//proconio macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); input_inner!{iter, $($r)*} }; ($($r:tt)*) => { let mut s = { use std::io::Read; let mut s = String::new(); std::io::stdin().read_to_string(&mut s).unwrap(); s }; let mut iter = s.split_whitespace(); input_inner!{iter, $($r)*} }; } macro_rules! input_inner { ($iter:expr) => {}; ($iter:expr, ) => {}; ($iter:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($iter, $t); input_inner!{$iter $($r)*} }; } macro_rules! read_value { ($iter:expr, ( $($t:tt),* )) => { ( $(read_value!($iter, $t)),* ) }; ($iter:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>() }; ($iter:expr, chars) => { read_value!($iter, String).chars().collect::<Vec<char>>() }; ($iter:expr, usize1) => { read_value!($iter, usize) - 1 }; ($iter:expr, $t:ty) => { $iter.next().unwrap().parse::<$t>().expect("Parse error") }; } fn main() { input!(n: usize, m: usize, D: [[i128; m]; n]); let mut memo = Vec::new(); for i in 0..n { let mut temp = Vec::new(); for j in 0..m { temp.push(D[i][j]) } temp.sort(); // println!("temp, {:?}", &temp); memo.push(temp); } // std::process::exit(0); let mut ok = 1000_000_000; let mut ng = -1; while ok - ng > 1 { let mid = (ok + ng) / 2; if check(mid, n, m, &memo) { ok = mid; } else { ng = mid; } } // eprintln!("ok {}", ok); // eprintln!("ng {}", ng); println!("{}", ok); } fn check(x: i128, n: usize, m: usize, memo: &Vec<Vec<i128>>) -> bool { // eprintln!("x {}", x); let mut res = false; let mut dp = vec![vec![false; m]; n]; for j in 0..m { dp[0][j] = true; } for i in 0..n - 1 { let ni = i + 1; let mut left = 0; let mut right = 0; let mut flagnums = vec![0; m + 1]; for j in 0..m { if !dp[i][j] { continue; } let preval = memo[i][j]; while (left < m - 1) & (memo[ni][left] < preval) { left += 1; } // 遷移不可能 if (left == m - 1) & (memo[ni][left] < preval) { break; } // right = right.max(left); while right < m { if memo[ni][right] <= preval + x { right += 1; } else { break; } } // eprintln!("i j left right {} {} {} {}", i, j, left, right); flagnums[left] += 1; flagnums[right] -= 1; // eprintln!("flag {:?}", flagnums); } for j in 0..m { flagnums[i + 1] += flagnums[i]; } // eprintln!("flag {:?}", flagnums); for j in 0..m { if flagnums[j] > 0 { dp[ni][j] = true; } } } for j in 0..m { if dp[n - 1][j] { res = true; // eprintln!("hoge"); break; } } res }