結果
問題 | No.755 Zero-Sum Rectangle |
ユーザー |
![]() |
提出日時 | 2018-12-03 00:52:14 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 198 ms / 2,000 ms |
コード長 | 1,214 bytes |
コンパイル時間 | 2,059 ms |
コンパイル使用メモリ | 160,004 KB |
実行使用メモリ | 13,756 KB |
最終ジャッジ日時 | 2024-07-01 05:30:55 |
合計ジャッジ時間 | 6,822 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 11 TLE * 1 |
ソースコード
#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; }