# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
169619 |
2019-12-21T16:37:14 Z |
davitmarg |
Bomb (IZhO17_bomb) |
C++17 |
|
1000 ms |
51840 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 = 1, 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;
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;
}
/*
4 2
1921
*/
Compilation message
bomb.cpp: In function 'void solve(int)':
bomb.cpp:66:28: warning: unused variable 'pos' [-Wunused-variable]
int l = 1, r = m, mid, pos = -1;
^~~
bomb.cpp: In function 'int main()':
bomb.cpp:87: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 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Incorrect |
2 ms |
504 KB |
Output isn't correct |
3 |
Incorrect |
206 ms |
20468 KB |
Output isn't correct |
4 |
Incorrect |
173 ms |
20472 KB |
Output isn't correct |
5 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
6 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
7 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
8 |
Incorrect |
3 ms |
504 KB |
Output isn't correct |
9 |
Incorrect |
3 ms |
504 KB |
Output isn't correct |
10 |
Incorrect |
2 ms |
508 KB |
Output isn't correct |
11 |
Incorrect |
2 ms |
504 KB |
Output isn't correct |
12 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
13 |
Incorrect |
2 ms |
504 KB |
Output isn't correct |
14 |
Incorrect |
2 ms |
504 KB |
Output isn't correct |
15 |
Incorrect |
2 ms |
504 KB |
Output isn't correct |
16 |
Incorrect |
2 ms |
504 KB |
Output isn't correct |
17 |
Incorrect |
6 ms |
888 KB |
Output isn't correct |
18 |
Incorrect |
5 ms |
892 KB |
Output isn't correct |
19 |
Incorrect |
9 ms |
1144 KB |
Output isn't correct |
20 |
Incorrect |
10 ms |
1144 KB |
Output isn't correct |
21 |
Incorrect |
5 ms |
760 KB |
Output isn't correct |
22 |
Incorrect |
7 ms |
1016 KB |
Output isn't correct |
23 |
Incorrect |
14 ms |
1272 KB |
Output isn't correct |
24 |
Incorrect |
8 ms |
1016 KB |
Output isn't correct |
25 |
Incorrect |
15 ms |
1272 KB |
Output isn't correct |
26 |
Incorrect |
16 ms |
1272 KB |
Output isn't correct |
27 |
Incorrect |
312 ms |
3452 KB |
Output isn't correct |
28 |
Incorrect |
325 ms |
3704 KB |
Output isn't correct |
29 |
Incorrect |
782 ms |
4612 KB |
Output isn't correct |
30 |
Execution timed out |
1050 ms |
5368 KB |
Time limit exceeded |
31 |
Incorrect |
642 ms |
4472 KB |
Output isn't correct |
32 |
Incorrect |
825 ms |
5112 KB |
Output isn't correct |
33 |
Execution timed out |
1085 ms |
5752 KB |
Time limit exceeded |
34 |
Incorrect |
268 ms |
3832 KB |
Output isn't correct |
35 |
Incorrect |
933 ms |
5880 KB |
Output isn't correct |
36 |
Execution timed out |
1065 ms |
5752 KB |
Time limit exceeded |
37 |
Incorrect |
2 ms |
504 KB |
Output isn't correct |
38 |
Execution timed out |
1085 ms |
51448 KB |
Time limit exceeded |
39 |
Incorrect |
2 ms |
504 KB |
Output isn't correct |
40 |
Execution timed out |
1082 ms |
14076 KB |
Time limit exceeded |
41 |
Incorrect |
2 ms |
504 KB |
Output isn't correct |
42 |
Incorrect |
20 ms |
1272 KB |
Output isn't correct |
43 |
Execution timed out |
1078 ms |
51456 KB |
Time limit exceeded |
44 |
Execution timed out |
1069 ms |
5752 KB |
Time limit exceeded |
45 |
Execution timed out |
1076 ms |
51616 KB |
Time limit exceeded |
46 |
Execution timed out |
1068 ms |
51668 KB |
Time limit exceeded |
47 |
Execution timed out |
1080 ms |
51580 KB |
Time limit exceeded |
48 |
Execution timed out |
1088 ms |
51596 KB |
Time limit exceeded |
49 |
Execution timed out |
1072 ms |
51576 KB |
Time limit exceeded |
50 |
Execution timed out |
1092 ms |
51448 KB |
Time limit exceeded |
51 |
Execution timed out |
1075 ms |
51576 KB |
Time limit exceeded |
52 |
Execution timed out |
1081 ms |
51644 KB |
Time limit exceeded |
53 |
Execution timed out |
1088 ms |
51576 KB |
Time limit exceeded |
54 |
Execution timed out |
1089 ms |
51704 KB |
Time limit exceeded |
55 |
Execution timed out |
1082 ms |
51620 KB |
Time limit exceeded |
56 |
Execution timed out |
1082 ms |
51840 KB |
Time limit exceeded |
57 |
Execution timed out |
1077 ms |
51576 KB |
Time limit exceeded |
58 |
Execution timed out |
1084 ms |
51552 KB |
Time limit exceeded |
59 |
Execution timed out |
1085 ms |
51576 KB |
Time limit exceeded |
60 |
Execution timed out |
1085 ms |
51668 KB |
Time limit exceeded |
61 |
Execution timed out |
1085 ms |
51704 KB |
Time limit exceeded |
62 |
Execution timed out |
1072 ms |
51596 KB |
Time limit exceeded |
63 |
Execution timed out |
1076 ms |
51640 KB |
Time limit exceeded |
64 |
Execution timed out |
1087 ms |
51576 KB |
Time limit exceeded |
65 |
Execution timed out |
1089 ms |
51488 KB |
Time limit exceeded |
66 |
Execution timed out |
1090 ms |
51448 KB |
Time limit exceeded |
67 |
Execution timed out |
1072 ms |
51576 KB |
Time limit exceeded |
68 |
Execution timed out |
1075 ms |
51448 KB |
Time limit exceeded |
69 |
Execution timed out |
1090 ms |
51448 KB |
Time limit exceeded |
70 |
Execution timed out |
1080 ms |
41664 KB |
Time limit exceeded |
71 |
Execution timed out |
1084 ms |
51424 KB |
Time limit exceeded |
72 |
Execution timed out |
1077 ms |
51576 KB |
Time limit exceeded |
73 |
Execution timed out |
1082 ms |
51320 KB |
Time limit exceeded |
74 |
Execution timed out |
1082 ms |
51312 KB |
Time limit exceeded |
75 |
Execution timed out |
1080 ms |
51320 KB |
Time limit exceeded |
76 |
Execution timed out |
1081 ms |
51192 KB |
Time limit exceeded |
77 |
Execution timed out |
1068 ms |
51192 KB |
Time limit exceeded |
78 |
Execution timed out |
1079 ms |
51064 KB |
Time limit exceeded |
79 |
Execution timed out |
1078 ms |
51128 KB |
Time limit exceeded |
80 |
Execution timed out |
1062 ms |
51112 KB |
Time limit exceeded |
81 |
Execution timed out |
1073 ms |
51320 KB |
Time limit exceeded |
82 |
Execution timed out |
1068 ms |
51340 KB |
Time limit exceeded |
83 |
Execution timed out |
1057 ms |
51284 KB |
Time limit exceeded |
84 |
Execution timed out |
1075 ms |
51320 KB |
Time limit exceeded |
85 |
Execution timed out |
1074 ms |
51320 KB |
Time limit exceeded |
86 |
Execution timed out |
1082 ms |
51364 KB |
Time limit exceeded |
87 |
Execution timed out |
1084 ms |
51192 KB |
Time limit exceeded |
88 |
Execution timed out |
1069 ms |
51068 KB |
Time limit exceeded |
89 |
Execution timed out |
1085 ms |
51180 KB |
Time limit exceeded |
90 |
Execution timed out |
1082 ms |
41368 KB |
Time limit exceeded |
91 |
Execution timed out |
1084 ms |
51064 KB |
Time limit exceeded |
92 |
Execution timed out |
1086 ms |
51056 KB |
Time limit exceeded |
93 |
Execution timed out |
1081 ms |
51172 KB |
Time limit exceeded |
94 |
Execution timed out |
1071 ms |
50808 KB |
Time limit exceeded |
95 |
Execution timed out |
1069 ms |
50804 KB |
Time limit exceeded |
96 |
Execution timed out |
1073 ms |
50848 KB |
Time limit exceeded |
97 |
Execution timed out |
1074 ms |
50984 KB |
Time limit exceeded |
98 |
Execution timed out |
1086 ms |
50804 KB |
Time limit exceeded |
99 |
Execution timed out |
1066 ms |
50868 KB |
Time limit exceeded |
100 |
Execution timed out |
1083 ms |
50888 KB |
Time limit exceeded |