結果

問題 No.755 Zero-Sum Rectangle
ユーザー 👑 kmjpkmjp
提出日時 2018-12-03 00:52:14
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 138 ms / 2,000 ms
コード長 1,214 bytes
コンパイル時間 2,326 ms
コンパイル使用メモリ 146,188 KB
実行使用メモリ 8,752 KB
最終ジャッジ日時 2023-09-13 21:01:50
合計ジャッジ時間 6,373 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
8,752 KB
testcase_01 AC 99 ms
4,376 KB
testcase_02 AC 77 ms
4,376 KB
testcase_03 AC 106 ms
4,380 KB
testcase_04 AC 121 ms
4,380 KB
testcase_05 AC 133 ms
4,384 KB
testcase_06 AC 85 ms
4,380 KB
testcase_07 AC 81 ms
4,380 KB
testcase_08 AC 109 ms
4,380 KB
testcase_09 AC 120 ms
4,380 KB
testcase_10 AC 138 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
evil_1 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,M;
int A[150][150];
ll S[150][150];

int X[10],Y[10];


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M;
	FOR(y,M) {
		FOR(x,M) {
			cin>>A[y][x];
			S[y+1][x+1]=S[y+1][x]+S[y][x+1]-S[y][x]+A[y][x];
		}
	}
	FOR(i,N) {
		cin>>Y[i]>>X[i];
		Y[i]--,X[i]--;
		int ret=0;
		for(int y1=0;y1<=Y[i];y1++) {
			for(int x1=0;x1<=X[i];x1++) {
				for(int y2=Y[i];y2<M;y2++) {
					for(int x2=X[i];x2<M;x2++) {
						ll sum=S[y2+1][x2+1]-S[y2+1][x1]-S[y1][x2+1]+S[y1][x1];
						ret+=sum==0;
					}
				}
			}
		}
		cout<<ret<<endl;
	}
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}
0