# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
169622 |
2019-12-21T16:42:37 Z |
davitmarg |
Bomb (IZhO17_bomb) |
C++17 |
|
1000 ms |
49656 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];
char x;
int ans = 1;
void add(int sy, int sx, int y, int x)
{
pr[sy][sx]++;
pr[y][x]++;
pr[sy][x]--;
pr[y][sx]--;
}
int get(int sy, int sx, int y, int x)
{
return a[y][x] - a[sy - 1][x] - a[y][sx - 1] + a[sy - 1][sx - 1];
}
bool check(int k, int q)
{
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++)
pr[i][j] = 0;
for (int i = 1; i + k - 1 <= n; i++)
for (int j = 1; j + q - 1 <= m; j++)
if (get(i, j, i + k - 1, j + q - 1) == k * q)
add(i, j, i + k, j + q);
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++)
{
pr[i][j] += pr[i - 1][j] + pr[i][j - 1] - pr[i - 1][j - 1];
if (get(i, j, i, j) != (bool)(pr[i][j]))
return 0;
}
return 1;
}
void solve(int k)
{
int l = max(ans / k, 1), r = m, mid;
while (l <= r)
{
mid = (l + r) / 2;
if (check(k, mid))
{
if (k * mid >= ans)
ans = k * mid;
l = mid + 1;
}
else
r = mid - 1;
}
}
int main()
{
cin >> n >> m;
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++)
{
scanf(" %c", &x);
a[i][j] += (x - '0');
a[i][j] += a[i - 1][j] + a[i][j - 1] - a[i - 1][j - 1];
}
for (int i = 1; i <= n; i++)
solve(i);
cout << ans << endl;
return 0;
}
/*
*/
Compilation message
bomb.cpp: In function 'int main()':
bomb.cpp:88: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 |
209 ms |
20472 KB |
Output is correct |
4 |
Correct |
173 ms |
20600 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 |
Correct |
2 ms |
504 KB |
Output is correct |
9 |
Correct |
2 ms |
504 KB |
Output is correct |
10 |
Correct |
2 ms |
504 KB |
Output is correct |
11 |
Correct |
2 ms |
504 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
2 ms |
504 KB |
Output is correct |
14 |
Correct |
2 ms |
504 KB |
Output is correct |
15 |
Correct |
2 ms |
504 KB |
Output is correct |
16 |
Correct |
2 ms |
504 KB |
Output is correct |
17 |
Correct |
5 ms |
888 KB |
Output is correct |
18 |
Correct |
5 ms |
888 KB |
Output is correct |
19 |
Correct |
9 ms |
1144 KB |
Output is correct |
20 |
Correct |
10 ms |
1144 KB |
Output is correct |
21 |
Correct |
5 ms |
888 KB |
Output is correct |
22 |
Correct |
7 ms |
1016 KB |
Output is correct |
23 |
Correct |
12 ms |
1144 KB |
Output is correct |
24 |
Correct |
8 ms |
1016 KB |
Output is correct |
25 |
Correct |
13 ms |
1144 KB |
Output is correct |
26 |
Correct |
15 ms |
1144 KB |
Output is correct |
27 |
Correct |
317 ms |
3448 KB |
Output is correct |
28 |
Correct |
328 ms |
3580 KB |
Output is correct |
29 |
Correct |
657 ms |
4524 KB |
Output is correct |
30 |
Correct |
957 ms |
5368 KB |
Output is correct |
31 |
Correct |
577 ms |
4216 KB |
Output is correct |
32 |
Correct |
773 ms |
4856 KB |
Output is correct |
33 |
Execution timed out |
1072 ms |
5496 KB |
Time limit exceeded |
34 |
Correct |
267 ms |
3960 KB |
Output is correct |
35 |
Correct |
910 ms |
5624 KB |
Output is correct |
36 |
Execution timed out |
1075 ms |
5624 KB |
Time limit exceeded |
37 |
Correct |
2 ms |
504 KB |
Output is correct |
38 |
Execution timed out |
1085 ms |
49400 KB |
Time limit exceeded |
39 |
Correct |
2 ms |
504 KB |
Output is correct |
40 |
Execution timed out |
1085 ms |
13432 KB |
Time limit exceeded |
41 |
Correct |
2 ms |
504 KB |
Output is correct |
42 |
Correct |
14 ms |
1272 KB |
Output is correct |
43 |
Execution timed out |
1085 ms |
49372 KB |
Time limit exceeded |
44 |
Execution timed out |
1079 ms |
5496 KB |
Time limit exceeded |
45 |
Execution timed out |
1091 ms |
49464 KB |
Time limit exceeded |
46 |
Execution timed out |
1085 ms |
49396 KB |
Time limit exceeded |
47 |
Execution timed out |
1091 ms |
49400 KB |
Time limit exceeded |
48 |
Execution timed out |
1085 ms |
49400 KB |
Time limit exceeded |
49 |
Execution timed out |
1074 ms |
49432 KB |
Time limit exceeded |
50 |
Execution timed out |
1083 ms |
49368 KB |
Time limit exceeded |
51 |
Execution timed out |
1068 ms |
49400 KB |
Time limit exceeded |
52 |
Execution timed out |
1082 ms |
49404 KB |
Time limit exceeded |
53 |
Execution timed out |
1080 ms |
49656 KB |
Time limit exceeded |
54 |
Execution timed out |
1082 ms |
49312 KB |
Time limit exceeded |
55 |
Execution timed out |
1075 ms |
49448 KB |
Time limit exceeded |
56 |
Execution timed out |
1081 ms |
49400 KB |
Time limit exceeded |
57 |
Execution timed out |
1080 ms |
49272 KB |
Time limit exceeded |
58 |
Execution timed out |
1083 ms |
49528 KB |
Time limit exceeded |
59 |
Execution timed out |
1087 ms |
49340 KB |
Time limit exceeded |
60 |
Execution timed out |
1084 ms |
49504 KB |
Time limit exceeded |
61 |
Execution timed out |
1082 ms |
49456 KB |
Time limit exceeded |
62 |
Execution timed out |
1073 ms |
49608 KB |
Time limit exceeded |
63 |
Execution timed out |
1087 ms |
49408 KB |
Time limit exceeded |
64 |
Execution timed out |
1084 ms |
49528 KB |
Time limit exceeded |
65 |
Execution timed out |
1086 ms |
49656 KB |
Time limit exceeded |
66 |
Execution timed out |
1079 ms |
49588 KB |
Time limit exceeded |
67 |
Execution timed out |
1086 ms |
49400 KB |
Time limit exceeded |
68 |
Execution timed out |
1086 ms |
49296 KB |
Time limit exceeded |
69 |
Execution timed out |
1089 ms |
49260 KB |
Time limit exceeded |
70 |
Execution timed out |
1084 ms |
39544 KB |
Time limit exceeded |
71 |
Execution timed out |
1079 ms |
49440 KB |
Time limit exceeded |
72 |
Execution timed out |
1091 ms |
49400 KB |
Time limit exceeded |
73 |
Execution timed out |
1086 ms |
49260 KB |
Time limit exceeded |
74 |
Execution timed out |
1076 ms |
49364 KB |
Time limit exceeded |
75 |
Execution timed out |
1078 ms |
49400 KB |
Time limit exceeded |
76 |
Execution timed out |
1076 ms |
49404 KB |
Time limit exceeded |
77 |
Execution timed out |
1084 ms |
49272 KB |
Time limit exceeded |
78 |
Execution timed out |
1081 ms |
49500 KB |
Time limit exceeded |
79 |
Execution timed out |
1072 ms |
49372 KB |
Time limit exceeded |
80 |
Execution timed out |
1078 ms |
49400 KB |
Time limit exceeded |
81 |
Execution timed out |
1077 ms |
49360 KB |
Time limit exceeded |
82 |
Execution timed out |
1085 ms |
49268 KB |
Time limit exceeded |
83 |
Execution timed out |
1089 ms |
49400 KB |
Time limit exceeded |
84 |
Execution timed out |
1087 ms |
49400 KB |
Time limit exceeded |
85 |
Execution timed out |
1084 ms |
49528 KB |
Time limit exceeded |
86 |
Execution timed out |
1078 ms |
49428 KB |
Time limit exceeded |
87 |
Execution timed out |
1074 ms |
49352 KB |
Time limit exceeded |
88 |
Execution timed out |
1094 ms |
49400 KB |
Time limit exceeded |
89 |
Execution timed out |
1079 ms |
49400 KB |
Time limit exceeded |
90 |
Execution timed out |
1074 ms |
39628 KB |
Time limit exceeded |
91 |
Execution timed out |
1075 ms |
49528 KB |
Time limit exceeded |
92 |
Execution timed out |
1082 ms |
49528 KB |
Time limit exceeded |
93 |
Execution timed out |
1085 ms |
49572 KB |
Time limit exceeded |
94 |
Execution timed out |
1075 ms |
49400 KB |
Time limit exceeded |
95 |
Execution timed out |
1082 ms |
49272 KB |
Time limit exceeded |
96 |
Execution timed out |
1088 ms |
49476 KB |
Time limit exceeded |
97 |
Execution timed out |
1086 ms |
49572 KB |
Time limit exceeded |
98 |
Execution timed out |
1087 ms |
49400 KB |
Time limit exceeded |
99 |
Execution timed out |
1071 ms |
49372 KB |
Time limit exceeded |
100 |
Execution timed out |
1092 ms |
49272 KB |
Time limit exceeded |