# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
169621 |
2019-12-21T16:39:17 Z |
davitmarg |
Bomb (IZhO17_bomb) |
C++17 |
|
1000 ms |
50112 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;
pair<int, int> s;
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 = s.first * s.second / k, r = m, mid, pos = -1;
while (l <= r)
{
mid = (l + r) / 2;
if (check(k, mid))
{
if (k * mid >= s.first * s.second)
s = MP(k, mid);
l = mid + 1;
}
else
r = mid - 1;
}
}
int main()
{
cin >> n >> m;
s = MP(1, 1);
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 << s.first * s.second << endl;
return 0;
}
/*
*/
Compilation message
bomb.cpp: In function 'void solve(int)':
bomb.cpp:66:49: warning: unused variable 'pos' [-Wunused-variable]
int l = s.first * s.second / k, r = m, mid, pos = -1;
^~~
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 |
Incorrect |
2 ms |
504 KB |
Output isn't correct |
3 |
Incorrect |
221 ms |
20504 KB |
Output isn't correct |
4 |
Incorrect |
224 ms |
20472 KB |
Output isn't correct |
5 |
Correct |
2 ms |
380 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 |
380 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 |
6 ms |
888 KB |
Output is correct |
18 |
Correct |
6 ms |
888 KB |
Output is correct |
19 |
Correct |
10 ms |
1116 KB |
Output is correct |
20 |
Correct |
10 ms |
1144 KB |
Output is correct |
21 |
Correct |
5 ms |
760 KB |
Output is correct |
22 |
Correct |
8 ms |
1016 KB |
Output is correct |
23 |
Correct |
12 ms |
1272 KB |
Output is correct |
24 |
Correct |
8 ms |
1016 KB |
Output is correct |
25 |
Correct |
14 ms |
1272 KB |
Output is correct |
26 |
Correct |
15 ms |
1272 KB |
Output is correct |
27 |
Correct |
318 ms |
3456 KB |
Output is correct |
28 |
Correct |
352 ms |
3576 KB |
Output is correct |
29 |
Correct |
663 ms |
4608 KB |
Output is correct |
30 |
Correct |
965 ms |
5496 KB |
Output is correct |
31 |
Correct |
583 ms |
4472 KB |
Output is correct |
32 |
Correct |
798 ms |
5008 KB |
Output is correct |
33 |
Execution timed out |
1083 ms |
5752 KB |
Time limit exceeded |
34 |
Correct |
287 ms |
3960 KB |
Output is correct |
35 |
Correct |
940 ms |
5888 KB |
Output is correct |
36 |
Execution timed out |
1082 ms |
5752 KB |
Time limit exceeded |
37 |
Correct |
2 ms |
532 KB |
Output is correct |
38 |
Execution timed out |
1081 ms |
49952 KB |
Time limit exceeded |
39 |
Correct |
2 ms |
504 KB |
Output is correct |
40 |
Execution timed out |
1078 ms |
13688 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 |
1067 ms |
49884 KB |
Time limit exceeded |
44 |
Execution timed out |
1083 ms |
5752 KB |
Time limit exceeded |
45 |
Execution timed out |
1080 ms |
49944 KB |
Time limit exceeded |
46 |
Execution timed out |
1074 ms |
50112 KB |
Time limit exceeded |
47 |
Execution timed out |
1083 ms |
49956 KB |
Time limit exceeded |
48 |
Execution timed out |
1079 ms |
49920 KB |
Time limit exceeded |
49 |
Execution timed out |
1076 ms |
49916 KB |
Time limit exceeded |
50 |
Execution timed out |
1083 ms |
49912 KB |
Time limit exceeded |
51 |
Execution timed out |
1082 ms |
49936 KB |
Time limit exceeded |
52 |
Execution timed out |
1070 ms |
50040 KB |
Time limit exceeded |
53 |
Execution timed out |
1081 ms |
50040 KB |
Time limit exceeded |
54 |
Execution timed out |
1073 ms |
49864 KB |
Time limit exceeded |
55 |
Execution timed out |
1079 ms |
49912 KB |
Time limit exceeded |
56 |
Execution timed out |
1077 ms |
49852 KB |
Time limit exceeded |
57 |
Execution timed out |
1090 ms |
49912 KB |
Time limit exceeded |
58 |
Execution timed out |
1092 ms |
49912 KB |
Time limit exceeded |
59 |
Execution timed out |
1088 ms |
49912 KB |
Time limit exceeded |
60 |
Execution timed out |
1067 ms |
50012 KB |
Time limit exceeded |
61 |
Execution timed out |
1077 ms |
50040 KB |
Time limit exceeded |
62 |
Execution timed out |
1084 ms |
49952 KB |
Time limit exceeded |
63 |
Execution timed out |
1083 ms |
49912 KB |
Time limit exceeded |
64 |
Execution timed out |
1082 ms |
50040 KB |
Time limit exceeded |
65 |
Execution timed out |
1088 ms |
49912 KB |
Time limit exceeded |
66 |
Execution timed out |
1063 ms |
50008 KB |
Time limit exceeded |
67 |
Execution timed out |
1067 ms |
49860 KB |
Time limit exceeded |
68 |
Execution timed out |
1081 ms |
49912 KB |
Time limit exceeded |
69 |
Execution timed out |
1079 ms |
49944 KB |
Time limit exceeded |
70 |
Execution timed out |
1080 ms |
40096 KB |
Time limit exceeded |
71 |
Execution timed out |
1082 ms |
49852 KB |
Time limit exceeded |
72 |
Execution timed out |
1076 ms |
49912 KB |
Time limit exceeded |
73 |
Execution timed out |
1075 ms |
49836 KB |
Time limit exceeded |
74 |
Execution timed out |
1072 ms |
50040 KB |
Time limit exceeded |
75 |
Execution timed out |
1078 ms |
49948 KB |
Time limit exceeded |
76 |
Execution timed out |
1080 ms |
49972 KB |
Time limit exceeded |
77 |
Execution timed out |
1087 ms |
49912 KB |
Time limit exceeded |
78 |
Execution timed out |
1074 ms |
49976 KB |
Time limit exceeded |
79 |
Execution timed out |
1080 ms |
49932 KB |
Time limit exceeded |
80 |
Execution timed out |
1085 ms |
49756 KB |
Time limit exceeded |
81 |
Execution timed out |
1082 ms |
49580 KB |
Time limit exceeded |
82 |
Execution timed out |
1079 ms |
49568 KB |
Time limit exceeded |
83 |
Execution timed out |
1086 ms |
49528 KB |
Time limit exceeded |
84 |
Execution timed out |
1084 ms |
49564 KB |
Time limit exceeded |
85 |
Execution timed out |
1076 ms |
49596 KB |
Time limit exceeded |
86 |
Execution timed out |
1070 ms |
49648 KB |
Time limit exceeded |
87 |
Execution timed out |
1081 ms |
49528 KB |
Time limit exceeded |
88 |
Execution timed out |
1078 ms |
49324 KB |
Time limit exceeded |
89 |
Execution timed out |
1083 ms |
49316 KB |
Time limit exceeded |
90 |
Execution timed out |
1075 ms |
39544 KB |
Time limit exceeded |
91 |
Execution timed out |
1080 ms |
49420 KB |
Time limit exceeded |
92 |
Execution timed out |
1074 ms |
49400 KB |
Time limit exceeded |
93 |
Execution timed out |
1086 ms |
49524 KB |
Time limit exceeded |
94 |
Execution timed out |
1079 ms |
49400 KB |
Time limit exceeded |
95 |
Execution timed out |
1071 ms |
49400 KB |
Time limit exceeded |
96 |
Execution timed out |
1078 ms |
49400 KB |
Time limit exceeded |
97 |
Execution timed out |
1087 ms |
49400 KB |
Time limit exceeded |
98 |
Execution timed out |
1086 ms |
49388 KB |
Time limit exceeded |
99 |
Execution timed out |
1079 ms |
49412 KB |
Time limit exceeded |
100 |
Execution timed out |
1084 ms |
49372 KB |
Time limit exceeded |