結果

問題 No.2225 Treasure Searching Rod (Easy)
ユーザー maguroflymagurofly
提出日時 2023-02-24 21:52:51
言語 Rust
(1.77.0)
結果
AC  
実行時間 13 ms / 2,000 ms
コード長 1,548 bytes
コンパイル時間 742 ms
コンパイル使用メモリ 152,444 KB
実行使用メモリ 4,352 KB
最終ジャッジ日時 2023-10-11 06:09:34
合計ジャッジ時間 2,113 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 13 ms
4,352 KB
testcase_08 AC 13 ms
4,348 KB
testcase_09 AC 13 ms
4,348 KB
testcase_10 AC 12 ms
4,352 KB
testcase_11 AC 12 ms
4,352 KB
testcase_12 AC 13 ms
4,352 KB
testcase_13 AC 13 ms
4,352 KB
testcase_14 AC 13 ms
4,348 KB
testcase_15 AC 12 ms
4,348 KB
testcase_16 AC 12 ms
4,352 KB
testcase_17 AC 12 ms
4,348 KB
testcase_18 AC 12 ms
4,348 KB
testcase_19 AC 12 ms
4,352 KB
testcase_20 AC 13 ms
4,348 KB
testcase_21 AC 5 ms
4,352 KB
testcase_22 AC 1 ms
4,348 KB
testcase_23 AC 4 ms
4,348 KB
testcase_24 AC 6 ms
4,352 KB
testcase_25 AC 3 ms
4,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#![allow(dead_code, unused_imports, unused_macros, non_snake_case)]

fn main() {
  let mut input = Input::new();

  let H = input.read::<usize>();
  let W = input.read::<usize>();
  let K = input.read::<usize>();
  let mut treasures = vec![vec![0; W]; H];
  for _ in 0 .. K {
    let x = input.read::<usize>() - 1;
    let y = input.read::<usize>() - 1;
    let v = input.read::<i64>();
    treasures[x][y] = v;
  }

  let mut ans = 0;
  for i0 in 0 .. H {
    for j0 in 0 .. W {
      for i in 0 .. H {
        for j in 0 .. W {
          if i + j >= i0 + j0 && i + j0 >= i0 + j {
            ans += treasures[i][j];
            ans %= 998244353;
          }
        }
      }
    }
  }

  println!("{}", ans);
}

type Int = i64;
const MOD: Int = 1_000_000_007;
const INF: Int = 1_000_000_000;
const YESNO: [&'static str; 2] = ["Yes", "No"];

pub struct Input {
  words: std::collections::VecDeque<String>,
}
impl Input {
  pub fn new() -> Self {
    use std::io::prelude::*;
    let mut stdin = std::io::stdin();
    let mut input = String::new();
    stdin.read_to_string(&mut input).unwrap();
    let words = input.split_ascii_whitespace().map(str::to_string).collect();
    Self { words }
  }

  pub fn read<T: std::str::FromStr>(&mut self) -> T {
    let res = self.words.pop_front().unwrap().parse();
    if let Ok(r) = res {
      r
    } else {
      panic!("read() failed")
    }
  }
}

fn yes() { println!("{}", YESNO[0]); }
fn no() { println!("{}", YESNO[1]); }
fn yesno(c: bool) { println!("{}", if c { YESNO[0] } else { YESNO[1] }); }
0