結果

問題 No.755 Zero-Sum Rectangle
ユーザー ducktailducktail
提出日時 2019-01-11 15:36:05
言語 Rust
(1.77.0)
結果
AC  
実行時間 188 ms / 2,000 ms
コード長 899 bytes
コンパイル時間 14,014 ms
コンパイル使用メモリ 401,840 KB
実行使用メモリ 7,296 KB
最終ジャッジ日時 2024-05-06 10:20:15
合計ジャッジ時間 18,130 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
7,296 KB
testcase_01 AC 158 ms
5,376 KB
testcase_02 AC 114 ms
5,376 KB
testcase_03 AC 150 ms
5,376 KB
testcase_04 AC 165 ms
5,376 KB
testcase_05 AC 168 ms
5,376 KB
testcase_06 AC 111 ms
5,376 KB
testcase_07 AC 104 ms
5,376 KB
testcase_08 AC 137 ms
5,376 KB
testcase_09 AC 161 ms
5,376 KB
testcase_10 AC 188 ms
5,376 KB
testcase_11 AC 1 ms
5,376 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