結果
問題 | No.755 Zero-Sum Rectangle |
ユーザー |
|
提出日時 | 2018-12-06 09:20:50 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 129 ms / 2,000 ms |
コード長 | 1,215 bytes |
コンパイル時間 | 1,850 ms |
コンパイル使用メモリ | 174,228 KB |
実行使用メモリ | 13,892 KB |
最終ジャッジ日時 | 2024-09-14 00:06:27 |
合計ジャッジ時間 | 6,521 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 11 TLE * 1 |
ソースコード
#include <bits/stdc++.h>#define FOR(v, a, b) for(int v = (a); v < (b); ++v)#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)#define REP(v, n) FOR(v, 0, n)#define REPE(v, n) FORE(v, 0, n)#define REV(v, a, b) for(int v = (a); v >= (b); --v)#define ALL(x) (x).begin(), (x).end()#define LLI long long intusing namespace std;template <typename T> using V = vector<T>;template <typename T, typename U> using P = pair<T,U>;template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}int main(){cin.tie(0);ios::sync_with_stdio(false);int n,m; cin >> n >> m;vector<vector<LLI>> a(m, vector<LLI>(m));REP(i,m) REP(j,m) cin >> a[i][j];vector<vector<LLI>> memo(m+1, vector<LLI>(m+1));REP(i,m) REP(j,m) memo[i+1][j+1] = a[i][j];FORE(i,1,m)REPE(j,m)memo[i][j] += memo[i-1][j];REPE(i,m)FORE(j,1,m)memo[i][j] += memo[i][j-1];REP(_,n){int x,y; cin >> x >> y;int ans = 0;FORE(x1,1,x) FORE(y1,1,y) FORE(x2,x,m) FORE(y2,y,m){if(memo[x2][y2] - memo[x1-1][y2] - memo[x2][y1-1] + memo[x1-1][y1-1] == 0) ++ans;}cout << ans << endl;}return 0;}