結果
問題 | No.755 Zero-Sum Rectangle |
ユーザー |
![]() |
提出日時 | 2018-12-06 02:46:41 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 1,613 ms / 2,000 ms |
コード長 | 1,272 bytes |
コンパイル時間 | 1,167 ms |
コンパイル使用メモリ | 102,044 KB |
実行使用メモリ | 10,752 KB |
最終ジャッジ日時 | 2024-09-13 12:45:33 |
合計ジャッジ時間 | 21,242 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 11 TLE * 1 |
ソースコード
#include <algorithm> #include <bitset> #include <cassert> #include <cctype> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstring> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <tuple> #include <unordered_map> #include <vector> #define rep(i, n) for (int i = 0; i < (int)(n); ++i) #define show(x) cout << #x << " = " << (x) << endl; using namespace std; using ll = long long; using pii = pair<int,int>; ll sum[135][135]; int main(){ int n,m; cin >> n >> m; rep(i,m){ rep(j,m){ cin >> sum[i][j]; } } rep(i,m)rep(j,m)sum[i][j+1] +=sum[i][j]; rep(i,m)rep(j,m)sum[i+1][j] +=sum[i][j]; while(n--){ int x,y; cin >> x >> y; x--,y--; int ans =0; rep(a,m)for(int b = a; b < m; b++)rep(c,m)for(int d = c; d < m; d++){ ll s = sum[b][d]; if(a>0)s -= sum[a-1][d]; if(c>0)s -= sum[b][c-1]; if(a>0 and c > 0) s+=sum[a-1][c-1]; if(a<=x and x <= b and c<= y and y<=d and s == 0)ans++; } cout << ans << endl; } }