結果

問題 No.755 Zero-Sum Rectangle
ユーザー chocoruskchocorusk
提出日時 2018-12-03 00:06:32
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 144 ms / 2,000 ms
コード長 846 bytes
コンパイル時間 887 ms
コンパイル使用メモリ 92,008 KB
実行使用メモリ 8,756 KB
最終ジャッジ日時 2023-09-13 21:00:09
合計ジャッジ時間 5,572 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
8,756 KB
testcase_01 AC 102 ms
4,380 KB
testcase_02 AC 81 ms
4,376 KB
testcase_03 AC 108 ms
4,376 KB
testcase_04 AC 122 ms
4,380 KB
testcase_05 AC 135 ms
4,380 KB
testcase_06 AC 89 ms
4,376 KB
testcase_07 AC 83 ms
4,380 KB
testcase_08 AC 112 ms
4,380 KB
testcase_09 AC 126 ms
4,380 KB
testcase_10 AC 144 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
evil_1 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <random>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n, m;
	cin>>n>>m;
	ll a[131][131], s[131][131]={};
	for(int i=1; i<=m; i++){
		for(int j=1; j<=m; j++){
			cin>>a[i][j];
			s[i][j]=s[i-1][j]+s[i][j-1]-s[i-1][j-1]+a[i][j];
		}
	}
	for(int i=0; i<n; i++){
		int x, y;
		cin>>x>>y;
		int ans=0;
		for(int a=1; a<=x; a++){
			for(int b=x; b<=m; b++){
				for(int c=1; c<=y; c++){
					for(int d=y; d<=m; d++){
						if(s[b][d]-s[a-1][d]-s[b][c-1]+s[a-1][c-1]==0) ans++;
					}
				}
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}
0