Submission #37654

# Submission time Handle Problem Language Result Execution time Memory
37654 2017-12-26T16:45:27 Z Kerim Bomb (IZhO17_bomb) C++14
100 / 100
903 ms 57352 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=2509;
char arr[N][N];
int up[N][N],down[N][N],ans[N];
int main(){
    //~ freopen("file.in", "r", stdin);
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			scanf(" %c",&arr[i][j]);
	int xx=n,yy=m;		
	for(int i=1;i<=n;i++){
		int cnt=0;
		for(int j=1;j<=m;j++){
			if(arr[i][j]=='1')
				cnt++;
			else{
				if(cnt)
					umin(yy,cnt);
				cnt=0;
			}
		}
		if(cnt)
			umin(yy,cnt);
	}
	for(int j=1;j<=m;j++){
		int cnt=0;
		for(int i=1;i<=n;i++){
			if(arr[i][j]=='1')
				up[i][j]=up[i-1][j]+1,cnt++;
			else{
				if(cnt)
					umin(xx,cnt);
				cnt=0;	
			}	
		}
		if(cnt)
			umin(xx,cnt);
		for(int i=n;i>=1;i--)
			if(arr[i][j]=='1')
				down[i][j]=down[i+1][j]+1;	
	}
	for(int i=1;i<=yy;i++)	
		ans[i]=xx;	
	for(int i=1;i<=n;i++){
		int cnt=0;
		int a=INF,b=INF;
		for(int j=1;j<=m;j++){
			if(arr[i][j]=='1'){
				umin(a,up[i][j]);
				umin(b,down[i][j]);
				umin(ans[++cnt],a+b-1);
			}
			else
				cnt=0,a=b=INF;
		}a=b=INF;cnt=0;
		for(int j=m;j>=1;j--){
			if(arr[i][j]=='1'){
				umin(a,up[i][j]);
				umin(b,down[i][j]);
				umin(ans[++cnt],a+b-1);
			}
			else
				cnt=0,a=b=INF;
		}
	}	
	int res=ans[1];
	for(int i=2;i<=yy;i++){
		umin(ans[i],ans[i-1]);
		umax(res,i*ans[i]);
	}printf("%d\n",res);
	return 0;
}

Compilation message

bomb.cpp: In function 'int main()':
bomb.cpp:26:21: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d",&n,&m);
                     ^
bomb.cpp:29:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf(" %c",&arr[i][j]);
                           ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 57352 KB Output is correct
2 Correct 0 ms 57352 KB Output is correct
3 Correct 0 ms 57352 KB Output is correct
4 Correct 0 ms 57352 KB Output is correct
5 Correct 0 ms 57352 KB Output is correct
6 Correct 0 ms 57352 KB Output is correct
7 Correct 0 ms 57352 KB Output is correct
8 Correct 0 ms 57352 KB Output is correct
9 Correct 0 ms 57352 KB Output is correct
10 Correct 0 ms 57352 KB Output is correct
11 Correct 0 ms 57352 KB Output is correct
12 Correct 0 ms 57352 KB Output is correct
13 Correct 0 ms 57352 KB Output is correct
14 Correct 0 ms 57352 KB Output is correct
15 Correct 0 ms 57352 KB Output is correct
16 Correct 0 ms 57352 KB Output is correct
17 Correct 0 ms 57352 KB Output is correct
18 Correct 0 ms 57352 KB Output is correct
19 Correct 0 ms 57352 KB Output is correct
20 Correct 0 ms 57352 KB Output is correct
21 Correct 0 ms 57352 KB Output is correct
22 Correct 0 ms 57352 KB Output is correct
23 Correct 0 ms 57352 KB Output is correct
24 Correct 0 ms 57352 KB Output is correct
25 Correct 0 ms 57352 KB Output is correct
26 Correct 0 ms 57352 KB Output is correct
27 Correct 6 ms 57352 KB Output is correct
28 Correct 6 ms 57352 KB Output is correct
29 Correct 9 ms 57352 KB Output is correct
30 Correct 6 ms 57352 KB Output is correct
31 Correct 9 ms 57352 KB Output is correct
32 Correct 13 ms 57352 KB Output is correct
33 Correct 23 ms 57352 KB Output is correct
34 Correct 3 ms 57352 KB Output is correct
35 Correct 16 ms 57352 KB Output is correct
36 Correct 16 ms 57352 KB Output is correct
37 Correct 0 ms 57352 KB Output is correct
38 Correct 856 ms 57352 KB Output is correct
39 Correct 0 ms 57352 KB Output is correct
40 Correct 79 ms 57352 KB Output is correct
41 Correct 0 ms 57352 KB Output is correct
42 Correct 0 ms 57352 KB Output is correct
43 Correct 736 ms 57352 KB Output is correct
44 Correct 19 ms 57352 KB Output is correct
45 Correct 733 ms 57352 KB Output is correct
46 Correct 699 ms 57352 KB Output is correct
47 Correct 719 ms 57352 KB Output is correct
48 Correct 683 ms 57352 KB Output is correct
49 Correct 836 ms 57352 KB Output is correct
50 Correct 739 ms 57352 KB Output is correct
51 Correct 609 ms 57352 KB Output is correct
52 Correct 703 ms 57352 KB Output is correct
53 Correct 696 ms 57352 KB Output is correct
54 Correct 606 ms 57352 KB Output is correct
55 Correct 606 ms 57352 KB Output is correct
56 Correct 819 ms 57352 KB Output is correct
57 Correct 609 ms 57352 KB Output is correct
58 Correct 646 ms 57352 KB Output is correct
59 Correct 639 ms 57352 KB Output is correct
60 Correct 759 ms 57352 KB Output is correct
61 Correct 819 ms 57352 KB Output is correct
62 Correct 863 ms 57352 KB Output is correct
63 Correct 903 ms 57352 KB Output is correct
64 Correct 583 ms 57352 KB Output is correct
65 Correct 729 ms 57352 KB Output is correct
66 Correct 623 ms 57352 KB Output is correct
67 Correct 739 ms 57352 KB Output is correct
68 Correct 773 ms 57352 KB Output is correct
69 Correct 566 ms 57352 KB Output is correct
70 Correct 296 ms 57352 KB Output is correct
71 Correct 499 ms 57352 KB Output is correct
72 Correct 526 ms 57352 KB Output is correct
73 Correct 573 ms 57352 KB Output is correct
74 Correct 576 ms 57352 KB Output is correct
75 Correct 589 ms 57352 KB Output is correct
76 Correct 606 ms 57352 KB Output is correct
77 Correct 593 ms 57352 KB Output is correct
78 Correct 536 ms 57352 KB Output is correct
79 Correct 569 ms 57352 KB Output is correct
80 Correct 529 ms 57352 KB Output is correct
81 Correct 479 ms 57352 KB Output is correct
82 Correct 613 ms 57352 KB Output is correct
83 Correct 559 ms 57352 KB Output is correct
84 Correct 459 ms 57352 KB Output is correct
85 Correct 603 ms 57352 KB Output is correct
86 Correct 819 ms 57352 KB Output is correct
87 Correct 526 ms 57352 KB Output is correct
88 Correct 556 ms 57352 KB Output is correct
89 Correct 673 ms 57352 KB Output is correct
90 Correct 333 ms 57352 KB Output is correct
91 Correct 573 ms 57352 KB Output is correct
92 Correct 673 ms 57352 KB Output is correct
93 Correct 833 ms 57352 KB Output is correct
94 Correct 656 ms 57352 KB Output is correct
95 Correct 616 ms 57352 KB Output is correct
96 Correct 646 ms 57352 KB Output is correct
97 Correct 779 ms 57352 KB Output is correct
98 Correct 629 ms 57352 KB Output is correct
99 Correct 589 ms 57352 KB Output is correct
100 Correct 719 ms 57352 KB Output is correct