結果

問題 No.1141 田グリッド
ユーザー tonyu0
提出日時 2020-07-31 23:18:18
言語 Rust
(1.83.0 + proconio)
結果
RE  
実行時間 -
コード長 1,286 bytes
コンパイル時間 14,376 ms
コンパイル使用メモリ 377,780 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2024-07-06 21:27:28
合計ジャッジ時間 14,635 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 5 RE * 26
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unused import: `std::cmp::*`
 --> src/main.rs:1:5
  |
1 | use std::cmp::*;
  |     ^^^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

ソースコード

diff #

use std::cmp::*;
use std::io::*;
const MOD: u64 = 1_000_000_007;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let h: usize = itr.next().unwrap().parse().unwrap();
    let w: usize = itr.next().unwrap().parse().unwrap();
    let mut a = vec![vec![0u64; w]; h];
    let mut row = vec![0; h];
    let mut col = vec![0; w];
    let mut ans = 1u64;
    for i in 0..h {
        for j in 0..w {
            a[i][j] = itr.next().unwrap().parse().unwrap();
            ans = ans * a[i][j];
        }
    }
    for i in 0..h {
        let mut tmp = 1;
        for j in 0..w {
            tmp = tmp * a[i][j];
        }
        row[i] = tmp;
    }
    for j in 0..w {
        let mut tmp = 1;
        for i in 0..h {
            tmp = tmp * a[i][j];
        }
        col[j] = tmp;
    }

    let mut out = Vec::new();
    let q: usize = itr.next().unwrap().parse().unwrap();
    for _ in 0..q {
        let r: usize = itr.next().unwrap().parse::<usize>().unwrap() - 1;
        let c: usize = itr.next().unwrap().parse::<usize>().unwrap() - 1;
        let now = ans / (row[r] / a[r][c]) / col[c] % MOD;
        writeln!(out, "{}", now).ok();
    }
    stdout().write_all(&out).unwrap();
}
0