結果
問題 | No.2509 Beam Shateki |
ユーザー | naut3 |
提出日時 | 2023-10-21 15:39:17 |
言語 | Rust (1.77.0 + proconio) |
結果 |
WA
|
実行時間 | - |
コード長 | 6,975 bytes |
コンパイル時間 | 14,617 ms |
コンパイル使用メモリ | 381,772 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-21 16:53:26 |
合計ジャッジ時間 | 20,864 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
5,248 KB |
testcase_01 | AC | 1 ms
5,376 KB |
testcase_02 | AC | 1 ms
5,376 KB |
testcase_03 | AC | 14 ms
5,376 KB |
testcase_04 | AC | 14 ms
5,376 KB |
testcase_05 | AC | 14 ms
5,376 KB |
testcase_06 | AC | 15 ms
5,376 KB |
testcase_07 | AC | 14 ms
5,376 KB |
testcase_08 | AC | 14 ms
5,376 KB |
testcase_09 | AC | 14 ms
5,376 KB |
testcase_10 | WA | - |
testcase_11 | AC | 14 ms
5,376 KB |
testcase_12 | AC | 14 ms
5,376 KB |
testcase_13 | AC | 166 ms
5,376 KB |
testcase_14 | AC | 168 ms
5,376 KB |
testcase_15 | AC | 165 ms
5,376 KB |
testcase_16 | AC | 164 ms
5,376 KB |
testcase_17 | AC | 169 ms
5,376 KB |
testcase_18 | AC | 168 ms
5,376 KB |
testcase_19 | AC | 162 ms
5,376 KB |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | AC | 178 ms
5,376 KB |
testcase_23 | AC | 179 ms
5,376 KB |
testcase_24 | AC | 176 ms
5,376 KB |
testcase_25 | AC | 167 ms
5,376 KB |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | AC | 169 ms
5,376 KB |
testcase_29 | AC | 164 ms
5,376 KB |
testcase_30 | AC | 170 ms
5,376 KB |
testcase_31 | WA | - |
testcase_32 | AC | 166 ms
5,376 KB |
testcase_33 | AC | 2 ms
5,376 KB |
testcase_34 | AC | 29 ms
5,376 KB |
testcase_35 | AC | 72 ms
5,376 KB |
testcase_36 | AC | 10 ms
5,376 KB |
testcase_37 | AC | 1 ms
5,376 KB |
testcase_38 | AC | 16 ms
5,376 KB |
testcase_39 | AC | 9 ms
5,376 KB |
testcase_40 | AC | 37 ms
5,376 KB |
testcase_41 | AC | 1 ms
5,376 KB |
testcase_42 | AC | 14 ms
5,376 KB |
testcase_43 | AC | 87 ms
5,376 KB |
testcase_44 | AC | 113 ms
5,376 KB |
testcase_45 | AC | 8 ms
5,376 KB |
testcase_46 | AC | 18 ms
5,376 KB |
testcase_47 | AC | 115 ms
5,376 KB |
testcase_48 | AC | 26 ms
5,376 KB |
testcase_49 | AC | 43 ms
5,376 KB |
testcase_50 | AC | 55 ms
5,376 KB |
testcase_51 | AC | 2 ms
5,376 KB |
testcase_52 | AC | 32 ms
5,376 KB |
testcase_53 | WA | - |
testcase_54 | WA | - |
testcase_55 | AC | 1 ms
5,376 KB |
testcase_56 | AC | 1 ms
5,376 KB |
testcase_57 | WA | - |
testcase_58 | WA | - |
testcase_59 | WA | - |
testcase_60 | WA | - |
testcase_61 | WA | - |
testcase_62 | WA | - |
testcase_63 | WA | - |
コンパイルメッセージ
warning: variable does not need to be mutable --> src/main.rs:44:21 | 44 | let mut ny = i - 1; | ----^^ | | | help: remove this `mut` | = note: `#[warn(unused_mut)]` on by default warning: variable does not need to be mutable --> src/main.rs:88:21 | 88 | let mut ny = j - 1; | ----^^ | | | help: remove this `mut` warning: variable does not need to be mutable --> src/main.rs:151:21 | 151 | let mut nx = i - 1; | ----^^ | | | help: remove this `mut` warning: variable does not need to be mutable --> src/main.rs:195:21 | 195 | let mut nx = j - 1; | ----^^ | | | help: remove this `mut`
ソースコード
#![allow(non_snake_case, unused_imports, unused_must_use)] use std::io::{self, prelude::*}; use std::str; fn main() { let (stdin, stdout) = (io::stdin(), io::stdout()); let mut scan = Scanner::new(stdin.lock()); let mut out = io::BufWriter::new(stdout.lock()); macro_rules! input { ($T: ty) => { scan.token::<$T>() }; ($T: ty, $N: expr) => { (0..$N).map(|_| scan.token::<$T>()).collect::<Vec<_>>() }; } let H = input!(usize); let W = input!(usize); let A = (0..H).map(|_| input!(usize, W)).collect::<Vec<_>>(); let mut ans = 0; // 横 for i in 0..H + 2 { for j in i + 1..H + 2 { let mut seen = vec![vec![false; W]; H]; if i == 0 { let mut ny = 0; let mut nx = 0; loop { if ny < H && nx < W { seen[ny][nx] = true; } else { break; } ny += 1; nx += 1; } } else if 0 < i && i < H + 1 { let mut ny = i - 1; let mut nx = 0; loop { if ny < H && nx < W { seen[ny][nx] = true; } else { break; } nx += 1; } } else { let mut ny = H - 1; let mut nx = 0; loop { if ny < H && nx < W { seen[ny][nx] = true; } else { break; } if ny == 0 { break; } ny -= 1; nx += 1; } } if j == 0 { let mut ny = 0; let mut nx = 0; loop { if ny < H && nx < W { seen[ny][nx] = true; } else { break; } ny += 1; nx += 1; } } else if 0 < j && j < H + 1 { let mut ny = j - 1; let mut nx = 0; loop { if ny < H && nx < W { seen[ny][nx] = true; } else { break; } nx += 1; } } else { let mut ny = H - 1; let mut nx = 0; loop { if ny < H && nx < W { seen[ny][nx] = true; } else { break; } if ny == 0 { break; } ny -= 1; nx += 1; } } let mut score = 0; for i in 0..H { for j in 0..W { if seen[i][j] { score += A[i][j]; } } } ans = std::cmp::max(ans, score); } } for i in 0..W + 2 { for j in i + 1..W + 2 { let mut seen = vec![vec![false; W]; H]; if i == 0 { let mut ny = 0; let mut nx = 0; loop { if ny < H && nx < W { seen[ny][nx] = true; } else { break; } ny += 1; nx += 1; } } else if 0 < i && i < W + 1 { let mut ny = 0; let mut nx = i - 1; loop { if ny < H && nx < W { seen[ny][nx] = true; } else { break; } ny += 1; } } else { let mut ny = 0; let mut nx = W - 1; loop { if ny < H && nx < W { seen[ny][nx] = true; } else { break; } if nx == 0 { break; } ny += 1; nx -= 1; } } if j == 0 { let mut ny = 0; let mut nx = 0; loop { if ny < H && nx < W { seen[ny][nx] = true; } else { break; } ny += 1; nx += 1; } } else if 0 < j && j < W + 1 { let mut ny = 0; let mut nx = j - 1; loop { if ny < H && nx < W { seen[ny][nx] = true; } else { break; } ny += 1; } } else { let mut ny = 0; let mut nx = W - 1; loop { if ny < H && nx < W { seen[ny][nx] = true; } else { break; } if nx == 0 { break; } ny += 1; nx -= 1; } } let mut score = 0; for i in 0..H { for j in 0..W { if seen[i][j] { score += A[i][j]; } } } ans = std::cmp::max(ans, score); } } writeln!(out, "{}", ans); } struct Scanner<R> { reader: R, buf_str: Vec<u8>, buf_iter: str::SplitWhitespace<'static>, } impl<R: BufRead> Scanner<R> { fn new(reader: R) -> Self { Self { reader, buf_str: vec![], buf_iter: "".split_whitespace(), } } fn token<T: str::FromStr>(&mut self) -> T { loop { if let Some(token) = self.buf_iter.next() { return token.parse().ok().expect("Failed parse"); } self.buf_str.clear(); self.reader .read_until(b'\n', &mut self.buf_str) .expect("Failed read"); self.buf_iter = unsafe { let slice = str::from_utf8_unchecked(&self.buf_str); std::mem::transmute(slice.split_whitespace()) } } } }