結果

問題 No.755 Zero-Sum Rectangle
ユーザー ducktailducktail
提出日時 2019-01-11 15:36:05
言語 Rust
(1.77.0)
結果
AC  
実行時間 160 ms / 2,000 ms
コード長 899 bytes
コンパイル時間 4,550 ms
コンパイル使用メモリ 141,616 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-19 03:11:23
合計ジャッジ時間 10,174 ms
ジャッジサーバーID
(参考情報)
judge9 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 135 ms
4,380 KB
testcase_02 AC 105 ms
4,376 KB
testcase_03 AC 135 ms
4,380 KB
testcase_04 AC 151 ms
4,376 KB
testcase_05 AC 151 ms
4,380 KB
testcase_06 AC 102 ms
4,376 KB
testcase_07 AC 94 ms
4,380 KB
testcase_08 AC 124 ms
4,380 KB
testcase_09 AC 140 ms
4,376 KB
testcase_10 AC 160 ms
4,380 KB
testcase_11 AC 1 ms
4,384 KB
evil_1 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

fn main(){
  let nm: Vec<usize> = read_vec();
  let n = nm[0];
  let m = nm[1];

  let mut sm: Vec<Vec<i64>> = vec![vec![0;m+1]; m+1];
  
  for i in 1 .. m+1 {
    let d: Vec<i64> = read_vec();
    for j in 1 .. m+1 {
      sm[i][j] = sm[i-1][j] + sm[i][j-1] - sm[i-1][j-1] + d[j-1]
    }
  }
  
  for _ in 0 .. n {
    let mut cnt: u32 = 0;
    let xy: Vec<usize> = read_vec();
    for i in xy[0] .. m+1 {
      for j in xy[1] .. m+1 {
        for k in 0 .. xy[0] {
          for l in 0 .. xy[1] {
            if sm[i][j] - sm[k][j] - sm[i][l] + sm[k][l] == 0 {cnt += 1;}
          }
        }
      }
    }
    println!("{}", cnt);
  }
  
  
}

fn read_vec<T>() -> Vec<T>
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.split_whitespace().map(|e| e.parse().unwrap()).collect()
}
0