結果
| 問題 | No.2509 Beam Shateki | 
| コンテスト | |
| ユーザー |  naut3 | 
| 提出日時 | 2023-10-21 15:39:17 | 
| 言語 | Rust (1.83.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 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 46 WA * 15 | 
コンパイルメッセージ
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())
            }
        }
    }
}
            
            
            
        