# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
170974 |
2019-12-26T21:12:08 Z |
davitmarg |
Bomb (IZhO17_bomb) |
C++17 |
|
960 ms |
74104 KB |
/*DavitMarg*/
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <stack>
#include <cassert>
#include <iterator>
#include <fstream>
#define mod 1000000007ll
#define LL long long
#define LD long double
#define MP make_pair
#define PB push_back
#define all(v) v.begin(), v.end()
using namespace std;
const int N = 2505;
int n, m, a[N][N], pr[N][N], nxt[N][N], d[N], Y, X, ans;
int get(int sy, int sx, int y, int x)
{
sy--;
sx--;
if (sy == -1 || sx == -1)
return pr[y][x];
return pr[y][x] - pr[sy][x] - pr[y][sx] + pr[sy][sx];
}
int main()
{
cin >> n >> m;
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++)
{
char x;
scanf(" %c", &x);
a[i][j] += (x - '0');
pr[i][j] = a[i][j] + pr[i - 1][j] + pr[i][j - 1] - pr[i - 1][j - 1];
}
X = m;
Y = n;
for (int i = 1; i <= n; i++)
for (int j = m; j >= 1; j--)
{
if (a[i][j])
nxt[i][j] = nxt[i][j + 1] + 1;
else
nxt[i][j] = 0;
if (a[i][j - 1] == 0 && a[i][j])
X = min(X, nxt[i][j]);
}
for (int j = 1; j <= m; j++)
{
int y = 0;
for (int i = 1; i <= n; i++)
{
if (a[i][j])
y++;
else
y = 0;
if (a[i][j] && a[i + 1][j] == 0)
Y = min(y, Y);
}
}
for (int i = 1; i <= Y; i++)
d[i] = X;
for (int j = 1; j <= m; j++)
{
int y = 0, x = X;
for (int i = 1; i <= n; i++)
{
if (y == Y)
y = 0;
if (a[i][j] == 0)
{
y = 0;
x = X;
}
else
{
y++;
x = min(x, nxt[i][j]);
if (get(i - y + 1, j - 1, i, j - 1) != y)
d[y] = min(x, d[y]);
}
//cout << i << " : " << j << " = " << y << " : " << x << endl;
}
}
for (int j = 1; j <= m; j++)
{
int y = 0, x = X;
for (int i = n; i >= 1; i--)
{
if (y == Y)
y = 0;
if (a[i][j] == 0)
{
y = 0;
x = X;
}
else
{
y++;
x = min(x, nxt[i][j]);
if (get(i, j - 1, i + y - 1, j - 1) != y)
d[y] = min(x, d[y]);
}
//cout << i << " : " << j << " = " << y << " : " << x << endl;
}
}
for (int i = 1; i <= Y; i++)
{
//d[i + 1] = min(d[i + 1], d[i]);
//cout << i << " : " << d[i] << endl;
ans = max(ans, i * d[i]);
}
cout << ans << endl;
return 0;
}
/*
5 6
100000
111110
111110
111110
100000
6 5
00110
01110
11110
11011
11111
11111
9 9
000000000
000111000
000111000
011111110
011101110
011111110
000111000
000111000
000000000
9 9
000000000
000111000
000111000
011111110
011101110
011111110
000111000
000111000
000000000
6 6
000111
000111
001111
111100
111000
111000
6 6
000000
111000
111100
001111
000111
000111
6 6
000111
011111
011111
111000
111000
111000
*/
Compilation message
bomb.cpp: In function 'int main()':
bomb.cpp:47:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf(" %c", &x);
~~~~~^~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
504 KB |
Output is correct |
3 |
Correct |
36 ms |
30456 KB |
Output is correct |
4 |
Correct |
36 ms |
30456 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 |
Incorrect |
3 ms |
376 KB |
Output isn't correct |
11 |
Incorrect |
2 ms |
632 KB |
Output isn't correct |
12 |
Correct |
2 ms |
504 KB |
Output is correct |
13 |
Incorrect |
2 ms |
504 KB |
Output isn't correct |
14 |
Correct |
2 ms |
504 KB |
Output is correct |
15 |
Incorrect |
2 ms |
504 KB |
Output isn't correct |
16 |
Correct |
2 ms |
504 KB |
Output is correct |
17 |
Incorrect |
3 ms |
1144 KB |
Output isn't correct |
18 |
Incorrect |
3 ms |
1144 KB |
Output isn't correct |
19 |
Incorrect |
3 ms |
1528 KB |
Output isn't correct |
20 |
Incorrect |
3 ms |
1528 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 |
4 ms |
1656 KB |
Output isn't correct |
24 |
Incorrect |
4 ms |
1404 KB |
Output isn't correct |
25 |
Incorrect |
4 ms |
1656 KB |
Output isn't correct |
26 |
Incorrect |
5 ms |
1656 KB |
Output isn't correct |
27 |
Incorrect |
13 ms |
4856 KB |
Output isn't correct |
28 |
Incorrect |
13 ms |
5112 KB |
Output isn't correct |
29 |
Incorrect |
18 ms |
6520 KB |
Output isn't correct |
30 |
Incorrect |
21 ms |
7672 KB |
Output isn't correct |
31 |
Incorrect |
19 ms |
6136 KB |
Output isn't correct |
32 |
Incorrect |
18 ms |
7092 KB |
Output isn't correct |
33 |
Incorrect |
22 ms |
8056 KB |
Output isn't correct |
34 |
Incorrect |
12 ms |
5624 KB |
Output isn't correct |
35 |
Incorrect |
23 ms |
8188 KB |
Output isn't correct |
36 |
Incorrect |
25 ms |
8056 KB |
Output isn't correct |
37 |
Correct |
3 ms |
632 KB |
Output is correct |
38 |
Correct |
933 ms |
73992 KB |
Output is correct |
39 |
Incorrect |
2 ms |
632 KB |
Output isn't correct |
40 |
Incorrect |
108 ms |
20060 KB |
Output isn't correct |
41 |
Incorrect |
2 ms |
632 KB |
Output isn't correct |
42 |
Incorrect |
4 ms |
1656 KB |
Output isn't correct |
43 |
Correct |
831 ms |
74008 KB |
Output is correct |
44 |
Incorrect |
26 ms |
8184 KB |
Output isn't correct |
45 |
Incorrect |
817 ms |
74076 KB |
Output isn't correct |
46 |
Correct |
777 ms |
73848 KB |
Output is correct |
47 |
Incorrect |
808 ms |
73908 KB |
Output isn't correct |
48 |
Incorrect |
773 ms |
73848 KB |
Output isn't correct |
49 |
Incorrect |
936 ms |
73976 KB |
Output isn't correct |
50 |
Incorrect |
782 ms |
73976 KB |
Output isn't correct |
51 |
Incorrect |
788 ms |
73976 KB |
Output isn't correct |
52 |
Incorrect |
780 ms |
73976 KB |
Output isn't correct |
53 |
Incorrect |
778 ms |
73980 KB |
Output isn't correct |
54 |
Incorrect |
662 ms |
74040 KB |
Output isn't correct |
55 |
Incorrect |
662 ms |
73904 KB |
Output isn't correct |
56 |
Correct |
917 ms |
74060 KB |
Output is correct |
57 |
Incorrect |
652 ms |
74048 KB |
Output isn't correct |
58 |
Incorrect |
659 ms |
73980 KB |
Output isn't correct |
59 |
Incorrect |
649 ms |
73848 KB |
Output isn't correct |
60 |
Correct |
748 ms |
73976 KB |
Output is correct |
61 |
Correct |
960 ms |
73848 KB |
Output is correct |
62 |
Correct |
937 ms |
74104 KB |
Output is correct |
63 |
Correct |
932 ms |
74020 KB |
Output is correct |
64 |
Correct |
640 ms |
73976 KB |
Output is correct |
65 |
Incorrect |
762 ms |
74056 KB |
Output isn't correct |
66 |
Incorrect |
775 ms |
73984 KB |
Output isn't correct |
67 |
Incorrect |
802 ms |
73840 KB |
Output isn't correct |
68 |
Incorrect |
824 ms |
74020 KB |
Output isn't correct |
69 |
Incorrect |
651 ms |
73920 KB |
Output isn't correct |
70 |
Incorrect |
364 ms |
59256 KB |
Output isn't correct |
71 |
Incorrect |
595 ms |
73976 KB |
Output isn't correct |
72 |
Incorrect |
644 ms |
73928 KB |
Output isn't correct |
73 |
Incorrect |
657 ms |
73984 KB |
Output isn't correct |
74 |
Incorrect |
652 ms |
74012 KB |
Output isn't correct |
75 |
Incorrect |
657 ms |
74096 KB |
Output isn't correct |
76 |
Incorrect |
662 ms |
73872 KB |
Output isn't correct |
77 |
Incorrect |
664 ms |
74024 KB |
Output isn't correct |
78 |
Incorrect |
681 ms |
73856 KB |
Output isn't correct |
79 |
Incorrect |
526 ms |
73848 KB |
Output isn't correct |
80 |
Incorrect |
524 ms |
73848 KB |
Output isn't correct |
81 |
Incorrect |
535 ms |
73976 KB |
Output isn't correct |
82 |
Incorrect |
680 ms |
73976 KB |
Output isn't correct |
83 |
Incorrect |
682 ms |
73968 KB |
Output isn't correct |
84 |
Incorrect |
524 ms |
73976 KB |
Output isn't correct |
85 |
Incorrect |
664 ms |
73976 KB |
Output isn't correct |
86 |
Incorrect |
888 ms |
73848 KB |
Output isn't correct |
87 |
Incorrect |
649 ms |
73976 KB |
Output isn't correct |
88 |
Incorrect |
675 ms |
74104 KB |
Output isn't correct |
89 |
Incorrect |
727 ms |
73976 KB |
Output isn't correct |
90 |
Incorrect |
402 ms |
59256 KB |
Output isn't correct |
91 |
Incorrect |
688 ms |
73976 KB |
Output isn't correct |
92 |
Incorrect |
738 ms |
73976 KB |
Output isn't correct |
93 |
Incorrect |
889 ms |
73976 KB |
Output isn't correct |
94 |
Incorrect |
736 ms |
74088 KB |
Output isn't correct |
95 |
Incorrect |
674 ms |
73944 KB |
Output isn't correct |
96 |
Incorrect |
683 ms |
74016 KB |
Output isn't correct |
97 |
Incorrect |
890 ms |
74104 KB |
Output isn't correct |
98 |
Incorrect |
678 ms |
74012 KB |
Output isn't correct |
99 |
Incorrect |
729 ms |
74060 KB |
Output isn't correct |
100 |
Incorrect |
943 ms |
73948 KB |
Output isn't correct |