結果

問題 No.755 Zero-Sum Rectangle
ユーザー HaarHaar
提出日時 2018-12-06 09:19:50
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,215 bytes
コンパイル時間 1,638 ms
コンパイル使用メモリ 170,216 KB
実行使用メモリ 7,768 KB
最終ジャッジ日時 2023-10-12 00:07:27
合計ジャッジ時間 6,572 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
7,768 KB
testcase_01 AC 89 ms
4,348 KB
testcase_02 AC 72 ms
4,348 KB
testcase_03 AC 95 ms
4,348 KB
testcase_04 AC 111 ms
4,352 KB
testcase_05 AC 121 ms
4,348 KB
testcase_06 AC 78 ms
4,348 KB
testcase_07 AC 71 ms
4,348 KB
testcase_08 AC 99 ms
4,348 KB
testcase_09 AC 111 ms
4,348 KB
testcase_10 AC 125 ms
4,348 KB
testcase_11 WA -
evil_1 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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 int
using 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<int>> a(m, vector<int>(m));

  REP(i,m) REP(j,m) cin >> a[i][j];

  vector<vector<int>> memo(m+1, vector<int>(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;
}
0