結果

問題 No.755 Zero-Sum Rectangle
ユーザー ikeyanabcd894ikeyanabcd894
提出日時 2019-04-27 11:23:10
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 129 ms / 2,000 ms
コード長 701 bytes
コンパイル時間 1,806 ms
コンパイル使用メモリ 146,836 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-18 08:22:57
合計ジャッジ時間 3,801 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 96 ms
4,380 KB
testcase_02 AC 71 ms
4,380 KB
testcase_03 AC 98 ms
4,376 KB
testcase_04 AC 108 ms
4,376 KB
testcase_05 AC 119 ms
4,380 KB
testcase_06 AC 77 ms
4,380 KB
testcase_07 AC 78 ms
4,376 KB
testcase_08 AC 101 ms
4,380 KB
testcase_09 AC 116 ms
4,376 KB
testcase_10 AC 129 ms
4,376 KB
testcase_11 AC 1 ms
4,384 KB
evil_1 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
long long A[140][140],s[140][140];

int main(){
  long long N,M;
  cin >> N >> M;
  vector<long long> x(140),y(140);
  for(int i=1;i<=M;i++){
    for(int j=1;j<=M;j++){cin >> A[i][j]; s[i][j]=A[i][j];}
  }
  for(int i=1;i<=N;i++){cin >> x[i] >> y[i];}
  for(int i=1;i<=M;i++){
    for(int j=1;j<=M;j++){s[i][j]+=s[i-1][j]+s[i][j-1]-s[i-1][j-1];}
  }
  for(int i=1;i<=N;i++){
    int cnt=0;
    for(int j=x[i];j<=M;j++){
      for(int k=y[i];k<=M;k++){
        for(int l=x[i];l>=1;l--){
          for(int m=y[i];m>=1;m--){
            if(s[j][k]-s[j][m-1]-s[l-1][k]+s[l-1][m-1]==0){cnt++;}
          }
        }
      }
    }
    cout << cnt << endl;
  }
}
0