Submission #172149

# Submission time Handle Problem Language Result Execution time Memory
172149 2019-12-31T11:34:11 Z MvC Bomb (IZhO17_bomb) C++11
40 / 100
1000 ms 131076 KB
//#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define mkp make_pair
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<62);
const int inf=(1<<30);
const int nmax=3e3+50;
const int mod=1e9+7;
using namespace std;
int n,m,i,j,cur,h[nmax][nmax],v[nmax][nmax],x,y,a[nmax][nmax],ad[nmax][nmax],b[nmax][nmax],rs,mid,l,r;
char c;
bool ok(int h,int w)
{
	int i,j,x;
	for(i=1;i<=n;i++)for(j=1;j<=m;j++)ad[i][j]=0;
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=m;j++)
		{
			if(i<=n-h+1 && j<=m-w+1)
			{
				x=b[i+h-1][j+w-1]-b[i+h-1][j-1]-b[i-1][j+w-1]+b[i-1][j-1];
				if(x==h*w)
				{
					ad[i][j]++;
					ad[i][j+w]--;
					ad[i+h][j]--;
					ad[i+h][j+w]++;
				}
			}
			ad[i][j]+=ad[i-1][j]+ad[i][j-1]-ad[i-1][j-1];
			if(!ad[i][j] && a[i][j])return 0;
		}
	}
	return 1;
}
int main()
{
	//freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>n>>m;
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=m;j++)
		{
			cin>>c;
			a[i][j]=(c=='1');
			b[i][j]=a[i][j]+b[i-1][j]+b[i][j-1]-b[i-1][j-1];
		}
	}
	x=y=inf;
	for(i=1;i<=n;i++)
	{
		for(j=m;j>=1;j--)
		{
			if(a[i][j])
			{
				h[i][j]=h[i][j+1]+1;
				if(!a[i][j-1])y=min(y,h[i][j]);
			}
		}
	}
	for(i=1;i<=m;i++)
	{
		for(j=n;j>=1;j--)
		{
			if(a[j][i])
			{
				v[j][i]=v[j+1][i]+1;
				if(!a[j-1][i])x=min(x,v[j][i]);
			}
		}
	}
	if(x==inf)rc(0);
	for(i=1;i<=x;i++)
	{
		l=1,r=y,cur=0;
		while(l<=r)
		{
			mid=(l+r)/2;
			if(ok(i,mid))cur=mid,l=mid+1;
			else r=mid-1;
		}
		rs=max(rs,i*cur);
	}
	cout<<rs<<endl;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 760 KB Output is correct
3 Correct 53 ms 50680 KB Output is correct
4 Correct 56 ms 50680 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 504 KB Output is correct
8 Correct 2 ms 764 KB Output is correct
9 Correct 2 ms 760 KB Output is correct
10 Correct 2 ms 672 KB Output is correct
11 Correct 2 ms 760 KB Output is correct
12 Correct 2 ms 632 KB Output is correct
13 Correct 2 ms 632 KB Output is correct
14 Correct 2 ms 760 KB Output is correct
15 Correct 2 ms 760 KB Output is correct
16 Correct 2 ms 760 KB Output is correct
17 Correct 4 ms 1780 KB Output is correct
18 Correct 3 ms 1528 KB Output is correct
19 Correct 5 ms 2040 KB Output is correct
20 Correct 5 ms 2040 KB Output is correct
21 Correct 3 ms 1144 KB Output is correct
22 Correct 3 ms 1656 KB Output is correct
23 Correct 6 ms 2168 KB Output is correct
24 Correct 5 ms 1912 KB Output is correct
25 Correct 8 ms 2424 KB Output is correct
26 Correct 8 ms 2552 KB Output is correct
27 Correct 12 ms 7800 KB Output is correct
28 Correct 16 ms 5624 KB Output is correct
29 Correct 364 ms 10488 KB Output is correct
30 Correct 286 ms 10872 KB Output is correct
31 Correct 167 ms 8300 KB Output is correct
32 Correct 213 ms 9976 KB Output is correct
33 Correct 444 ms 12152 KB Output is correct
34 Correct 17 ms 6264 KB Output is correct
35 Correct 51 ms 8948 KB Output is correct
36 Correct 467 ms 13560 KB Output is correct
37 Correct 2 ms 760 KB Output is correct
38 Runtime error 437 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
39 Correct 2 ms 760 KB Output is correct
40 Execution timed out 1068 ms 33628 KB Time limit exceeded
41 Correct 3 ms 760 KB Output is correct
42 Correct 13 ms 2552 KB Output is correct
43 Runtime error 387 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
44 Execution timed out 1080 ms 12792 KB Time limit exceeded
45 Runtime error 412 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
46 Runtime error 364 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
47 Runtime error 392 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
48 Runtime error 376 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
49 Runtime error 434 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
50 Runtime error 380 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
51 Runtime error 376 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
52 Runtime error 375 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
53 Runtime error 372 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
54 Execution timed out 1092 ms 131072 KB Time limit exceeded
55 Execution timed out 1085 ms 131072 KB Time limit exceeded
56 Runtime error 427 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
57 Execution timed out 1096 ms 124024 KB Time limit exceeded
58 Execution timed out 1082 ms 129024 KB Time limit exceeded
59 Execution timed out 1082 ms 125892 KB Time limit exceeded
60 Runtime error 409 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
61 Runtime error 429 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
62 Runtime error 431 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
63 Runtime error 433 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
64 Runtime error 340 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
65 Runtime error 388 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
66 Runtime error 363 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
67 Runtime error 380 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
68 Runtime error 394 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
69 Execution timed out 1085 ms 121848 KB Time limit exceeded
70 Execution timed out 1075 ms 85212 KB Time limit exceeded
71 Execution timed out 1090 ms 114936 KB Time limit exceeded
72 Execution timed out 1087 ms 120440 KB Time limit exceeded
73 Execution timed out 1082 ms 121340 KB Time limit exceeded
74 Execution timed out 1076 ms 122360 KB Time limit exceeded
75 Execution timed out 1089 ms 124060 KB Time limit exceeded
76 Execution timed out 1095 ms 125352 KB Time limit exceeded
77 Execution timed out 1082 ms 126044 KB Time limit exceeded
78 Execution timed out 1091 ms 126328 KB Time limit exceeded
79 Execution timed out 1084 ms 98524 KB Time limit exceeded
80 Execution timed out 1086 ms 99704 KB Time limit exceeded
81 Execution timed out 1081 ms 100040 KB Time limit exceeded
82 Execution timed out 1085 ms 129724 KB Time limit exceeded
83 Execution timed out 1086 ms 128664 KB Time limit exceeded
84 Execution timed out 1077 ms 94416 KB Time limit exceeded
85 Execution timed out 1090 ms 128228 KB Time limit exceeded
86 Runtime error 414 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
87 Execution timed out 1092 ms 126072 KB Time limit exceeded
88 Execution timed out 1084 ms 127224 KB Time limit exceeded
89 Runtime error 359 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
90 Execution timed out 1086 ms 99620 KB Time limit exceeded
91 Execution timed out 1070 ms 131044 KB Time limit exceeded
92 Runtime error 367 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
93 Runtime error 408 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
94 Runtime error 356 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
95 Execution timed out 1089 ms 127488 KB Time limit exceeded
96 Execution timed out 1089 ms 127480 KB Time limit exceeded
97 Runtime error 415 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
98 Execution timed out 1092 ms 126692 KB Time limit exceeded
99 Runtime error 357 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
100 Runtime error 413 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)