結果
問題 | No.755 Zero-Sum Rectangle |
ユーザー |
|
提出日時 | 2018-12-03 03:43:21 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 552 ms / 2,000 ms |
コード長 | 840 bytes |
コンパイル時間 | 659 ms |
コンパイル使用メモリ | 67,796 KB |
実行使用メモリ | 10,272 KB |
最終ジャッジ日時 | 2024-07-01 05:33:11 |
合計ジャッジ時間 | 8,272 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 11 TLE * 1 |
ソースコード
#include <iostream>#include <map>using namespace std;int n, m;long long a[130][130];long long S[131][131];long long f(int y1, int y2, int x1, int x2) {return S[y2][x2] - S[y2][x1] - S[y1][x2] + S[y1][x1];}int main() {cin >> n >> m;for (int i = 0; i < m; i++) {for (int j = 0; j < m; j++) {cin >> a[i][j];S[i + 1][j + 1] = S[i + 1][j] + S[i][j + 1] - S[i][j] + a[i][j];}}while (n--) {int y, x;cin >> y >> x;y--; x--;long long ans = 0;for (int a = 0; a <= y; a++) {for (int b = y + 1; b <= m; b++) {map<long long, int> mp;for (int c = 0; c <= x; c++) {mp[f(a, b, c, x)]++;}for (int c = x + 1; c <= m; c++) {ans += mp[-f(a, b, x, c)];}}}cout << ans << endl;}return 0;}