結果
問題 | No.755 Zero-Sum Rectangle |
ユーザー |
|
提出日時 | 2019-01-11 15:36:05 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 186 ms / 2,000 ms |
コード長 | 899 bytes |
コンパイル時間 | 12,371 ms |
コンパイル使用メモリ | 403,248 KB |
実行使用メモリ | 10,496 KB |
最終ジャッジ日時 | 2024-11-28 16:18:37 |
合計ジャッジ時間 | 18,047 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 11 TLE * 1 |
ソースコード
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()}