結果
問題 | No.2225 Treasure Searching Rod (Easy) |
ユーザー |
|
提出日時 | 2023-02-24 21:52:51 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 14 ms / 2,000 ms |
コード長 | 1,548 bytes |
コンパイル時間 | 12,462 ms |
コンパイル使用メモリ | 400,628 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-13 05:24:11 |
合計ジャッジ時間 | 13,760 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 |
ソースコード
#![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] }); }