# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
91548 |
2018-12-28T09:30:15 Z |
davitmarg |
Bomb (IZhO17_bomb) |
C++17 |
|
778 ms |
49852 KB |
/*
DEATH-MATCH
Davit-Marg
*/
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iterator>
#include <ctype.h>
#include <stdlib.h>
#include <fstream>
#define mod 1000000007ll
#define LL long long
#define LD long double
#define MP make_pair
#define PB push_back
using namespace std;
int n, m,w,h,l,r,mid;
int mp[2503][2503],pr[2503][2503];
char tmp;
int sum(int ys,int xs,int y,int x)
{
xs--;
ys--;
return pr[y][x] - pr[y][xs] - pr[ys][x] + pr[ys][xs];
}
bool check(int x)
{
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++)
if (mp[i][j] && !mp[i - 1][j] && !mp[i][j - 1])
{
int s = sum(i, j, i + x - 1, j + w - 1);
if (i + x - 1 > n || j + w - 1 > m)
return 0;
if (s != x * w)
return 0;
}
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++)
if (mp[i][j] && !mp[i + 1][j] && !mp[i][j + 1])
{
int s = sum(i-x+1,j-w+1,i, j);
if (i - x + 1 < 1 || j - w + 1 < 1)
return 0;
if (s != x * w)
return 0;
}
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++)
if (mp[i][j] && !mp[i - 1][j] && !mp[i][j + 1])
{
int s = sum(i, j - w + 1, i + x - 1, j);
if (i + x - 1 > n || j - w + 1 < 1)
return 0;
if (s != x * w)
return 0;
}
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++)
if (mp[i][j] && !mp[i + 1][j] && !mp[i][j - 1])
{
int s = sum(i - x + 1, j, i, j + w - 1);
if (j + w - 1 > m || i - x + 1 < 1)
return 0;
if (s != x * w)
return 0;
}
return 1;
}
int main()
{
cin >> n >> m;
w = m;
h = n;
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++)
{
cin >> tmp;
mp[i][j] = tmp - '0';
pr[i][j] = pr[i - 1][j] + pr[i][j - 1] - pr[i - 1][j - 1]+mp[i][j];
}
for (int i = 1; i <= n; i++)
{
int sum = 0;
for (int j = 1; j <= m; j++)
{
sum += mp[i][j];
if (mp[i][j] == 0)
{
if (sum)
w = min(sum,w);
sum = 0;
}
}
if(sum)
w = min(sum, w);
}
r = n;
for (int i = 1; i <= m; i++)
{
int sum = 0;
for (int j = 1; j <= n; j++)
{
sum += mp[j][i];
if (mp[j][i] == 0)
{
if (sum)
r = min(sum, r);
sum = 0;
}
}
}
l = 1;
h = 1;
while (l <= r)
{
mid = (l + r) / 2;
if (check(mid))
{
h = mid;
l = mid + 1;
}
else
r = mid - 1;
}
cout << max(w * h,1) << endl;
return 0;
}
/*
5 6
000000
111110
111111
111111
000000
7 8
01001110
01001110
01001100
00000000
01000000
01000000
01000000
7 8
01000000
00000000
00000000
00000000
00000000
00000000
00000000
7 8
11111111
11111111
11111111
11100111
11111111
11111111
11111111
7 8
00000000
00011000
00011000
00000000
00011111
00011111
00000000
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
600 KB |
Output is correct |
3 |
Correct |
20 ms |
20556 KB |
Output is correct |
4 |
Correct |
21 ms |
20560 KB |
Output is correct |
5 |
Correct |
2 ms |
20560 KB |
Output is correct |
6 |
Correct |
2 ms |
20560 KB |
Output is correct |
7 |
Correct |
2 ms |
20560 KB |
Output is correct |
8 |
Incorrect |
2 ms |
20560 KB |
Output isn't correct |
9 |
Incorrect |
2 ms |
20560 KB |
Output isn't correct |
10 |
Incorrect |
1 ms |
20560 KB |
Output isn't correct |
11 |
Incorrect |
2 ms |
20560 KB |
Output isn't correct |
12 |
Correct |
1 ms |
20560 KB |
Output is correct |
13 |
Correct |
2 ms |
20560 KB |
Output is correct |
14 |
Correct |
2 ms |
20560 KB |
Output is correct |
15 |
Incorrect |
2 ms |
20560 KB |
Output isn't correct |
16 |
Correct |
2 ms |
20560 KB |
Output is correct |
17 |
Correct |
2 ms |
20560 KB |
Output is correct |
18 |
Incorrect |
3 ms |
20560 KB |
Output isn't correct |
19 |
Incorrect |
3 ms |
20560 KB |
Output isn't correct |
20 |
Incorrect |
3 ms |
20560 KB |
Output isn't correct |
21 |
Incorrect |
3 ms |
20560 KB |
Output isn't correct |
22 |
Incorrect |
3 ms |
20560 KB |
Output isn't correct |
23 |
Incorrect |
3 ms |
20560 KB |
Output isn't correct |
24 |
Incorrect |
3 ms |
20560 KB |
Output isn't correct |
25 |
Incorrect |
3 ms |
20560 KB |
Output isn't correct |
26 |
Correct |
3 ms |
20560 KB |
Output is correct |
27 |
Correct |
9 ms |
20560 KB |
Output is correct |
28 |
Incorrect |
11 ms |
20560 KB |
Output isn't correct |
29 |
Incorrect |
14 ms |
20560 KB |
Output isn't correct |
30 |
Incorrect |
20 ms |
20560 KB |
Output isn't correct |
31 |
Incorrect |
16 ms |
20560 KB |
Output isn't correct |
32 |
Incorrect |
17 ms |
20560 KB |
Output isn't correct |
33 |
Incorrect |
20 ms |
20560 KB |
Output isn't correct |
34 |
Incorrect |
10 ms |
20560 KB |
Output isn't correct |
35 |
Incorrect |
19 ms |
20560 KB |
Output isn't correct |
36 |
Correct |
21 ms |
20560 KB |
Output is correct |
37 |
Correct |
2 ms |
20560 KB |
Output is correct |
38 |
Correct |
687 ms |
49696 KB |
Output is correct |
39 |
Correct |
2 ms |
49696 KB |
Output is correct |
40 |
Incorrect |
70 ms |
49696 KB |
Output isn't correct |
41 |
Incorrect |
2 ms |
49696 KB |
Output isn't correct |
42 |
Incorrect |
3 ms |
49696 KB |
Output isn't correct |
43 |
Correct |
598 ms |
49696 KB |
Output is correct |
44 |
Incorrect |
19 ms |
49696 KB |
Output isn't correct |
45 |
Incorrect |
434 ms |
49696 KB |
Output isn't correct |
46 |
Correct |
613 ms |
49696 KB |
Output is correct |
47 |
Incorrect |
496 ms |
49696 KB |
Output isn't correct |
48 |
Incorrect |
443 ms |
49696 KB |
Output isn't correct |
49 |
Correct |
483 ms |
49696 KB |
Output is correct |
50 |
Incorrect |
444 ms |
49696 KB |
Output isn't correct |
51 |
Incorrect |
453 ms |
49696 KB |
Output isn't correct |
52 |
Incorrect |
441 ms |
49696 KB |
Output isn't correct |
53 |
Incorrect |
440 ms |
49696 KB |
Output isn't correct |
54 |
Incorrect |
454 ms |
49696 KB |
Output isn't correct |
55 |
Incorrect |
454 ms |
49696 KB |
Output isn't correct |
56 |
Correct |
778 ms |
49696 KB |
Output is correct |
57 |
Incorrect |
462 ms |
49696 KB |
Output isn't correct |
58 |
Incorrect |
466 ms |
49696 KB |
Output isn't correct |
59 |
Incorrect |
437 ms |
49696 KB |
Output isn't correct |
60 |
Correct |
536 ms |
49696 KB |
Output is correct |
61 |
Incorrect |
528 ms |
49696 KB |
Output isn't correct |
62 |
Correct |
587 ms |
49696 KB |
Output is correct |
63 |
Correct |
624 ms |
49696 KB |
Output is correct |
64 |
Correct |
613 ms |
49696 KB |
Output is correct |
65 |
Incorrect |
447 ms |
49696 KB |
Output isn't correct |
66 |
Incorrect |
433 ms |
49696 KB |
Output isn't correct |
67 |
Incorrect |
418 ms |
49780 KB |
Output isn't correct |
68 |
Incorrect |
426 ms |
49780 KB |
Output isn't correct |
69 |
Incorrect |
469 ms |
49780 KB |
Output isn't correct |
70 |
Incorrect |
351 ms |
49780 KB |
Output isn't correct |
71 |
Incorrect |
575 ms |
49780 KB |
Output isn't correct |
72 |
Incorrect |
604 ms |
49780 KB |
Output isn't correct |
73 |
Incorrect |
540 ms |
49780 KB |
Output isn't correct |
74 |
Incorrect |
568 ms |
49780 KB |
Output isn't correct |
75 |
Incorrect |
552 ms |
49780 KB |
Output isn't correct |
76 |
Incorrect |
533 ms |
49852 KB |
Output isn't correct |
77 |
Incorrect |
541 ms |
49852 KB |
Output isn't correct |
78 |
Incorrect |
578 ms |
49852 KB |
Output isn't correct |
79 |
Incorrect |
541 ms |
49852 KB |
Output isn't correct |
80 |
Incorrect |
519 ms |
49852 KB |
Output isn't correct |
81 |
Incorrect |
702 ms |
49852 KB |
Output isn't correct |
82 |
Incorrect |
618 ms |
49852 KB |
Output isn't correct |
83 |
Incorrect |
605 ms |
49852 KB |
Output isn't correct |
84 |
Incorrect |
481 ms |
49852 KB |
Output isn't correct |
85 |
Incorrect |
553 ms |
49852 KB |
Output isn't correct |
86 |
Incorrect |
482 ms |
49852 KB |
Output isn't correct |
87 |
Correct |
580 ms |
49852 KB |
Output is correct |
88 |
Incorrect |
596 ms |
49852 KB |
Output isn't correct |
89 |
Incorrect |
543 ms |
49852 KB |
Output isn't correct |
90 |
Incorrect |
365 ms |
49852 KB |
Output isn't correct |
91 |
Incorrect |
559 ms |
49852 KB |
Output isn't correct |
92 |
Incorrect |
519 ms |
49852 KB |
Output isn't correct |
93 |
Incorrect |
472 ms |
49852 KB |
Output isn't correct |
94 |
Incorrect |
525 ms |
49852 KB |
Output isn't correct |
95 |
Incorrect |
596 ms |
49852 KB |
Output isn't correct |
96 |
Incorrect |
595 ms |
49852 KB |
Output isn't correct |
97 |
Incorrect |
467 ms |
49852 KB |
Output isn't correct |
98 |
Incorrect |
609 ms |
49852 KB |
Output isn't correct |
99 |
Incorrect |
558 ms |
49852 KB |
Output isn't correct |
100 |
Incorrect |
485 ms |
49852 KB |
Output isn't correct |