結果
| 問題 | No.755 Zero-Sum Rectangle | 
| コンテスト | |
| ユーザー |  edamame882 | 
| 提出日時 | 2019-07-25 18:34:05 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 861 ms / 2,000 ms | 
| コード長 | 1,617 bytes | 
| コンパイル時間 | 1,666 ms | 
| コンパイル使用メモリ | 169,904 KB | 
| 実行使用メモリ | 13,880 KB | 
| 最終ジャッジ日時 | 2024-07-02 06:15:46 | 
| 合計ジャッジ時間 | 13,384 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 11 TLE * 1 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
//container util
#define all(x) (x).begin(),(x).end()
//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};
//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
ll board[150][150];
ll imos2(int x1, int y1, int x2, int y2){
  return board[y1][x1] - board[y1][x2-1] - board[y2-1][x1] + board[y2-1][x2-1];
}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,m;
  cin >> n >> m;
  memset(board,0,sizeof(board));
  FOR(i,1,m+1)FOR(j,1,m+1) cin >> board[i][j];
  rep(i,m+1)rep(j,m+1) board[i][j+1] += board[i][j];
  rep(i,m+1)rep(j,m+1) board[j+1][i] += board[j][i];
  rep(_,n){
    int x , y;
    cin >> y >> x;
    ll cnt = 0;
    FOR(si,1,m+1)  FOR(ei,si,m+1) FOR(sj,1,m+1) FOR(ej,sj,m+1){
      if(si <= y && y <= ei && sj <= x && x <= ej){
        if(imos2(ej ,ei, sj, si) == 0) {
          cnt++;
          // cout << si << "," << sj << " " << ei << "," << ej << endl;
        }
      }
    }
    cout << cnt << endl;
  }
  return 0;
}
            
            
            
        