# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
169916 |
2019-12-23T09:17:05 Z |
stefdasca |
Bomb (IZhO17_bomb) |
C++14 |
|
559 ms |
59640 KB |
#include<bits/stdc++.h>
#define god dimasi5eks
#pragma GCC optimize("O3")
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define mod 1000000007
#define dancila 3.14159265359
#define eps 1e-9
using namespace std;
typedef long long ll;
int add(int a, int b)
{
ll x = a+b;
if(x >= mod)
x -= mod;
if(x < 0)
x += mod;
return x;
}
ll mul(ll a, ll b)
{
return (a*b) % mod;
}
ll pw(ll a, ll b)
{
ll ans = 1;
while(b)
{
if(b & 1)
ans = (ans * a) % mod;
a = (a * a) % mod;
b >>= 1;
}
return ans;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
long long rand_seed()
{
long long a = rng();
return a;
}
char c[2600][2600];
int n, m, mars[2600][2600], sp[2600][2600];
int sum(int xa, int ya, int xb, int yb)
{
return sp[xb][yb] - sp[xa - 1][yb] - sp[xb][ya - 1] + sp[xa - 1][ya - 1];
}
bool chk(int i, int j)
{
for(int q = i; q <= n; ++q)
for(int p = j; p <= m; ++p)
{
if(sp[q][p] - sp[q - i][p] - sp[q][p - j] + sp[q - i][p - j] == i * j)
{
mars[q - i + 1][p - j + 1]++;
mars[q + 1][p - j + 1]--;
mars[q - i + 1][p + 1]--;
mars[q + 1][p + 1]++;
}
}
bool ok = 1;
for(int q = 1; q <= n; ++q)
for(int p = 1; p <= m; ++p)
{
mars[q][p] = mars[q][p] + mars[q-1][p] + mars[q][p-1] - mars[q-1][p-1];
if(c[q][p] == '1' && !mars[q][p])
{
ok = 0;
p = m+1;
q = n+1;
}
}
for(int q = 1; q <= n; ++q)
for(int p = 1; p <= m; ++p)
mars[q][p] = 0;
return ok;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n >> m;
for(int i = 1; i <= n; ++i)
cin >> (c[i] + 1);
int xx = 0;
for(int i = 1; i <= n; ++i)
for(int j = 1; j <= m; ++j)
xx += (c[i][j] == '0');
if(!xx)
{
cout << n*m;
return 0;
}
for(int i = 1; i <= n; ++i)
for(int j = 1; j <= m; ++j)
sp[i][j] = (c[i][j] - '0') + sp[i-1][j] + sp[i][j-1] - sp[i-1][j-1];
int mnx = m, mny = n;
for(int i = 1; i <= n; ++i)
{
int str = 0;
for(int j = 1; j <= m; ++j)
{
if(c[i][j] == '1')
++str;
else
{
if(str)
mnx = min(mnx, str);
str = 0;
}
}
if(str)
mnx = min(mnx, str);
}
for(int j = 1; j <= m; ++j)
{
int str = 0;
for(int i = 1; i <= n; ++i)
{
if(c[i][j] == '1')
++str;
else
{
if(str)
mny = min(mny, str);
str = 0;
}
}
if(str)
mny = min(mny, str);
}
int mxans = 0;
int st = 1;
int dr = mny;
int ans = 1;
while(st <= dr)
{
int mid = (st + dr) / 2;
if(chk(mid, mnx))
ans = mid, st = mid + 1;
else
dr = mid - 1;
}
mxans = max(mxans, ans * mnx);
st = mxans / mny + 1;
dr = mnx;
ans = 1;
while(st <= dr)
{
int mid = (st + dr) / 2;
if(chk(mny, mid))
ans = mid, st = mid + 1;
else
dr = mid - 1;
}
mxans = max(mxans, mny * ans);
if(n <= 450 && m <= 450)
{
int mxans = 0;
for(int i = mny; i >= 1; --i)
{
if(i * m <= mxans)
break;
int st = mxans / i + 1;
int dr = m;
int ans = 0;
while(st <= dr)
{
int mid = (st + dr) / 2;
if(chk(i, mid))
ans = mid, st = mid + 1;
else
dr = mid - 1;
}
mxans = max(mxans, i * ans);
}
}
cout << mxans;
return 0;
}
Compilation message
bomb.cpp: In function 'bool chk(int, int)':
bomb.cpp:70:26: warning: assuming signed overflow does not occur when assuming that (X + c) >= X is always true [-Wstrict-overflow]
for(int p = 1; p <= m; ++p)
~~^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
632 KB |
Output is correct |
3 |
Correct |
27 ms |
26744 KB |
Output is correct |
4 |
Correct |
27 ms |
26872 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 |
376 KB |
Output is correct |
8 |
Incorrect |
2 ms |
632 KB |
Output isn't correct |
9 |
Incorrect |
2 ms |
504 KB |
Output isn't correct |
10 |
Correct |
2 ms |
504 KB |
Output is correct |
11 |
Incorrect |
2 ms |
632 KB |
Output isn't correct |
12 |
Correct |
2 ms |
508 KB |
Output is correct |
13 |
Correct |
2 ms |
504 KB |
Output is correct |
14 |
Correct |
2 ms |
504 KB |
Output is correct |
15 |
Incorrect |
2 ms |
604 KB |
Output isn't correct |
16 |
Correct |
2 ms |
632 KB |
Output is correct |
17 |
Correct |
3 ms |
1016 KB |
Output is correct |
18 |
Incorrect |
3 ms |
1144 KB |
Output isn't correct |
19 |
Incorrect |
5 ms |
1400 KB |
Output isn't correct |
20 |
Incorrect |
5 ms |
1400 KB |
Output isn't correct |
21 |
Incorrect |
3 ms |
1016 KB |
Output isn't correct |
22 |
Incorrect |
3 ms |
1272 KB |
Output isn't correct |
23 |
Incorrect |
5 ms |
1528 KB |
Output isn't correct |
24 |
Incorrect |
4 ms |
1272 KB |
Output isn't correct |
25 |
Incorrect |
8 ms |
1528 KB |
Output isn't correct |
26 |
Correct |
5 ms |
1528 KB |
Output is correct |
27 |
Correct |
9 ms |
4344 KB |
Output is correct |
28 |
Incorrect |
19 ms |
4344 KB |
Output isn't correct |
29 |
Incorrect |
140 ms |
5752 KB |
Output isn't correct |
30 |
Incorrect |
350 ms |
6648 KB |
Output isn't correct |
31 |
Incorrect |
188 ms |
5240 KB |
Output isn't correct |
32 |
Incorrect |
292 ms |
6056 KB |
Output isn't correct |
33 |
Incorrect |
534 ms |
7032 KB |
Output isn't correct |
34 |
Incorrect |
18 ms |
4860 KB |
Output isn't correct |
35 |
Incorrect |
69 ms |
6904 KB |
Output isn't correct |
36 |
Correct |
243 ms |
6940 KB |
Output is correct |
37 |
Correct |
3 ms |
504 KB |
Output is correct |
38 |
Correct |
19 ms |
7416 KB |
Output is correct |
39 |
Correct |
3 ms |
632 KB |
Output is correct |
40 |
Correct |
50 ms |
15836 KB |
Output is correct |
41 |
Correct |
2 ms |
632 KB |
Output is correct |
42 |
Incorrect |
7 ms |
1528 KB |
Output isn't correct |
43 |
Correct |
406 ms |
58488 KB |
Output is correct |
44 |
Incorrect |
555 ms |
6904 KB |
Output isn't correct |
45 |
Incorrect |
413 ms |
58360 KB |
Output isn't correct |
46 |
Correct |
264 ms |
58232 KB |
Output is correct |
47 |
Incorrect |
412 ms |
58360 KB |
Output isn't correct |
48 |
Correct |
433 ms |
58232 KB |
Output is correct |
49 |
Correct |
211 ms |
58500 KB |
Output is correct |
50 |
Correct |
461 ms |
58436 KB |
Output is correct |
51 |
Correct |
472 ms |
58460 KB |
Output is correct |
52 |
Correct |
446 ms |
58416 KB |
Output is correct |
53 |
Correct |
430 ms |
58548 KB |
Output is correct |
54 |
Correct |
436 ms |
58360 KB |
Output is correct |
55 |
Correct |
418 ms |
58464 KB |
Output is correct |
56 |
Correct |
398 ms |
58232 KB |
Output is correct |
57 |
Correct |
456 ms |
58456 KB |
Output is correct |
58 |
Correct |
525 ms |
58616 KB |
Output is correct |
59 |
Correct |
479 ms |
58232 KB |
Output is correct |
60 |
Correct |
273 ms |
58212 KB |
Output is correct |
61 |
Correct |
281 ms |
58360 KB |
Output is correct |
62 |
Correct |
420 ms |
57976 KB |
Output is correct |
63 |
Correct |
401 ms |
58232 KB |
Output is correct |
64 |
Correct |
350 ms |
58204 KB |
Output is correct |
65 |
Correct |
383 ms |
58232 KB |
Output is correct |
66 |
Correct |
437 ms |
58360 KB |
Output is correct |
67 |
Correct |
469 ms |
58232 KB |
Output is correct |
68 |
Correct |
510 ms |
58232 KB |
Output is correct |
69 |
Correct |
496 ms |
58232 KB |
Output is correct |
70 |
Incorrect |
249 ms |
46584 KB |
Output isn't correct |
71 |
Incorrect |
430 ms |
57976 KB |
Output isn't correct |
72 |
Incorrect |
437 ms |
58108 KB |
Output isn't correct |
73 |
Incorrect |
416 ms |
58076 KB |
Output isn't correct |
74 |
Incorrect |
409 ms |
57976 KB |
Output isn't correct |
75 |
Incorrect |
414 ms |
58104 KB |
Output isn't correct |
76 |
Incorrect |
430 ms |
58104 KB |
Output isn't correct |
77 |
Incorrect |
452 ms |
58068 KB |
Output isn't correct |
78 |
Incorrect |
449 ms |
58160 KB |
Output isn't correct |
79 |
Incorrect |
315 ms |
58232 KB |
Output isn't correct |
80 |
Incorrect |
310 ms |
58320 KB |
Output isn't correct |
81 |
Incorrect |
357 ms |
58280 KB |
Output isn't correct |
82 |
Incorrect |
483 ms |
59000 KB |
Output isn't correct |
83 |
Incorrect |
507 ms |
59004 KB |
Output isn't correct |
84 |
Incorrect |
251 ms |
59000 KB |
Output isn't correct |
85 |
Incorrect |
434 ms |
59256 KB |
Output isn't correct |
86 |
Incorrect |
332 ms |
59640 KB |
Output isn't correct |
87 |
Correct |
400 ms |
59256 KB |
Output is correct |
88 |
Incorrect |
478 ms |
59056 KB |
Output isn't correct |
89 |
Incorrect |
387 ms |
59328 KB |
Output isn't correct |
90 |
Incorrect |
268 ms |
47832 KB |
Output isn't correct |
91 |
Incorrect |
559 ms |
59456 KB |
Output isn't correct |
92 |
Incorrect |
476 ms |
59000 KB |
Output isn't correct |
93 |
Incorrect |
375 ms |
59256 KB |
Output isn't correct |
94 |
Incorrect |
425 ms |
59000 KB |
Output isn't correct |
95 |
Incorrect |
489 ms |
59176 KB |
Output isn't correct |
96 |
Incorrect |
459 ms |
59100 KB |
Output isn't correct |
97 |
Incorrect |
325 ms |
59248 KB |
Output isn't correct |
98 |
Incorrect |
493 ms |
59128 KB |
Output isn't correct |
99 |
Incorrect |
403 ms |
59256 KB |
Output isn't correct |
100 |
Incorrect |
375 ms |
59256 KB |
Output isn't correct |