답안 #37651

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
37651 2017-12-26T16:18:38 Z Kerim Bomb (IZhO17_bomb) C++14
41 / 100
1000 ms 57168 KB
#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
const int N=2505;
char arr[N][N];
int zero[N][N],n,m,vis[N][N];
int get(int x,int y,int xx,int yy){
	return zero[xx][yy]-zero[xx][y-1]-zero[x-1][yy]+zero[x-1][y-1];
}
bool ok(int x,int y){
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			vis[i][j]=0;
	for(int i=1;i+x-1<=n;i++)
		for(int j=1;j+y-1<=m;j++)
			if(!get(i,j,i+x-1,j+y-1)){
				vis[i+x-1][j+y-1]++;
				vis[i-1][j-1]++;
				vis[i+x-1][j-1]--;
				vis[i-1][j+y-1]--;
			}
	for(int i=n;i>=1;i--)
		for(int j=m;j>=1;j--){
			vis[i][j]+=vis[i+1][j]+vis[i][j+1]-vis[i+1][j+1];
			if(!vis[i][j] and arr[i][j]=='1')
				return 0;
		}
	return 1;	
}
int main(){
    //~ freopen("file.in", "r", stdin);
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++){
			char c;
			scanf(" %c",&c);
			if(c=='0')
				zero[i][j]++;
			zero[i][j]+=zero[i-1][j]+zero[i][j-1]-zero[i-1][j-1];	
			arr[i][j]=c;
		}
	if(get(1,1,n,m)==n*m){
		puts("0");
		return 0;
	}		
	int p=0;		
	for(int i=m;i>=1;i--)		
		if(ok(1,i)){
			p=i;
			break;
		}
	int ans=p;	
	for(int i=2;i<=n;i++){
		while(p>=1 and !ok(i,p))
			p--;
		if(p>=1 and ok(i,p))
			umax(ans,i*p);
	}	
	printf("%d\n",ans);
	return 0;
}

Compilation message

bomb.cpp: In function 'int main()':
bomb.cpp:48:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&n,&m);
                        ^
bomb.cpp:52:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf(" %c",&c);
                   ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 57168 KB Output is correct
2 Correct 0 ms 57168 KB Output is correct
3 Correct 9 ms 57168 KB Output is correct
4 Correct 19 ms 57168 KB Output is correct
5 Correct 6 ms 57168 KB Output is correct
6 Correct 3 ms 57168 KB Output is correct
7 Correct 0 ms 57168 KB Output is correct
8 Correct 0 ms 57168 KB Output is correct
9 Correct 0 ms 57168 KB Output is correct
10 Correct 0 ms 57168 KB Output is correct
11 Correct 0 ms 57168 KB Output is correct
12 Correct 0 ms 57168 KB Output is correct
13 Correct 0 ms 57168 KB Output is correct
14 Correct 0 ms 57168 KB Output is correct
15 Correct 0 ms 57168 KB Output is correct
16 Correct 0 ms 57168 KB Output is correct
17 Correct 0 ms 57168 KB Output is correct
18 Correct 0 ms 57168 KB Output is correct
19 Correct 3 ms 57168 KB Output is correct
20 Correct 3 ms 57168 KB Output is correct
21 Correct 3 ms 57168 KB Output is correct
22 Correct 3 ms 57168 KB Output is correct
23 Correct 3 ms 57168 KB Output is correct
24 Correct 3 ms 57168 KB Output is correct
25 Correct 6 ms 57168 KB Output is correct
26 Correct 3 ms 57168 KB Output is correct
27 Correct 49 ms 57168 KB Output is correct
28 Correct 219 ms 57168 KB Output is correct
29 Correct 273 ms 57168 KB Output is correct
30 Correct 543 ms 57168 KB Output is correct
31 Correct 379 ms 57168 KB Output is correct
32 Correct 399 ms 57168 KB Output is correct
33 Correct 676 ms 57168 KB Output is correct
34 Correct 116 ms 57168 KB Output is correct
35 Correct 563 ms 57168 KB Output is correct
36 Correct 546 ms 57168 KB Output is correct
37 Correct 0 ms 57168 KB Output is correct
38 Execution timed out 1000 ms 57168 KB Execution timed out
39 Correct 0 ms 57168 KB Output is correct
40 Execution timed out 1000 ms 57168 KB Execution timed out
41 Correct 0 ms 57168 KB Output is correct
42 Correct 6 ms 57168 KB Output is correct
43 Execution timed out 1000 ms 57168 KB Execution timed out
44 Correct 836 ms 57168 KB Output is correct
45 Execution timed out 1000 ms 57168 KB Execution timed out
46 Execution timed out 1000 ms 57168 KB Execution timed out
47 Execution timed out 1000 ms 57168 KB Execution timed out
48 Execution timed out 1000 ms 57168 KB Execution timed out
49 Execution timed out 1000 ms 57168 KB Execution timed out
50 Execution timed out 1000 ms 57168 KB Execution timed out
51 Execution timed out 1000 ms 57168 KB Execution timed out
52 Execution timed out 1000 ms 57168 KB Execution timed out
53 Execution timed out 1000 ms 57168 KB Execution timed out
54 Execution timed out 1000 ms 57168 KB Execution timed out
55 Execution timed out 1000 ms 57168 KB Execution timed out
56 Execution timed out 1000 ms 57168 KB Execution timed out
57 Execution timed out 1000 ms 57168 KB Execution timed out
58 Execution timed out 1000 ms 57168 KB Execution timed out
59 Execution timed out 1000 ms 57168 KB Execution timed out
60 Execution timed out 1000 ms 57168 KB Execution timed out
61 Execution timed out 1000 ms 57168 KB Execution timed out
62 Execution timed out 1000 ms 57168 KB Execution timed out
63 Execution timed out 1000 ms 57168 KB Execution timed out
64 Execution timed out 1000 ms 57168 KB Execution timed out
65 Execution timed out 1000 ms 57168 KB Execution timed out
66 Execution timed out 1000 ms 57168 KB Execution timed out
67 Execution timed out 1000 ms 57168 KB Execution timed out
68 Execution timed out 1000 ms 57168 KB Execution timed out
69 Execution timed out 1000 ms 57168 KB Execution timed out
70 Execution timed out 1000 ms 57168 KB Execution timed out
71 Execution timed out 1000 ms 57168 KB Execution timed out
72 Execution timed out 1000 ms 57168 KB Execution timed out
73 Execution timed out 1000 ms 57168 KB Execution timed out
74 Execution timed out 1000 ms 57168 KB Execution timed out
75 Execution timed out 1000 ms 57168 KB Execution timed out
76 Execution timed out 1000 ms 57168 KB Execution timed out
77 Execution timed out 1000 ms 57168 KB Execution timed out
78 Execution timed out 1000 ms 57168 KB Execution timed out
79 Execution timed out 1000 ms 57168 KB Execution timed out
80 Execution timed out 1000 ms 57168 KB Execution timed out
81 Execution timed out 1000 ms 57168 KB Execution timed out
82 Execution timed out 1000 ms 57168 KB Execution timed out
83 Execution timed out 1000 ms 57168 KB Execution timed out
84 Execution timed out 1000 ms 57168 KB Execution timed out
85 Execution timed out 1000 ms 57168 KB Execution timed out
86 Execution timed out 1000 ms 57168 KB Execution timed out
87 Execution timed out 1000 ms 57168 KB Execution timed out
88 Execution timed out 1000 ms 57168 KB Execution timed out
89 Execution timed out 1000 ms 57168 KB Execution timed out
90 Execution timed out 1000 ms 57168 KB Execution timed out
91 Execution timed out 1000 ms 57168 KB Execution timed out
92 Execution timed out 1000 ms 57168 KB Execution timed out
93 Execution timed out 1000 ms 57168 KB Execution timed out
94 Execution timed out 1000 ms 57168 KB Execution timed out
95 Execution timed out 1000 ms 57168 KB Execution timed out
96 Execution timed out 1000 ms 57168 KB Execution timed out
97 Execution timed out 1000 ms 57168 KB Execution timed out
98 Execution timed out 1000 ms 57168 KB Execution timed out
99 Execution timed out 1000 ms 57168 KB Execution timed out
100 Execution timed out 1000 ms 57168 KB Execution timed out