結果

問題 No.755 Zero-Sum Rectangle
ユーザー akakimidoriakakimidori
提出日時 2018-12-03 06:06:32
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 121 ms / 2,000 ms
コード長 701 bytes
コンパイル時間 563 ms
コンパイル使用メモリ 29,952 KB
実行使用メモリ 6,160 KB
最終ジャッジ日時 2023-09-13 21:05:59
合計ジャッジ時間 5,718 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,160 KB
testcase_01 AC 87 ms
4,376 KB
testcase_02 AC 69 ms
4,376 KB
testcase_03 AC 91 ms
4,380 KB
testcase_04 AC 105 ms
4,376 KB
testcase_05 AC 115 ms
4,376 KB
testcase_06 AC 75 ms
4,376 KB
testcase_07 AC 69 ms
4,376 KB
testcase_08 AC 94 ms
4,380 KB
testcase_09 AC 106 ms
4,376 KB
testcase_10 AC 121 ms
4,376 KB
testcase_11 AC 0 ms
4,380 KB
evil_1 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>
#include<stdlib.h>

typedef long long int int64;

#define POS(i,j) ((i)*(m+1)+(j))

void run(void){
  int n,m;
  scanf("%d%d",&n,&m);
  int64 *a=(int64 *)calloc((m+1)*(m+1),sizeof(int64));
  int i,j;
  for(i=1;i<=m;i++){
    for(j=1;j<=m;j++){
      scanf("%lld",a+POS(i,j));
      a[POS(i,j)]+=a[POS(i-1,j)]+a[POS(i,j-1)]-a[POS(i-1,j-1)];
    }
  }
  while(n--){
    int x,y;
    scanf("%d%d",&x,&y);
    int cnt=0;
    for(i=x;i>=1;i--){
      for(j=x;j<=m;j++){
	int k,l;
	for(k=y;k>=1;k--){
	  for(l=y;l<=m;l++){
	    if(a[POS(j,l)]-a[POS(j,k-1)]-a[POS(i-1,l)]+a[POS(i-1,k-1)]==0) cnt++;
	  }
	}
      }
    }
    printf("%d\n",cnt);
  }
}

int main(void){
  run();
  return 0;
}
0