# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
91423 |
2018-12-27T12:29:28 Z |
Vardanyan |
Bomb (IZhO17_bomb) |
C++14 |
|
1000 ms |
94568 KB |
#include<bits/stdc++.h>
using namespace std;
const int N = 2505;
int a[N][N];
int pref[N][N];
int pref2[N][N];
int calc1(int x1,int y1,int x2,int y2){
return pref[x2][y2]-pref[x2][y1-1]-pref[x1-1][y2]+pref[x1-1][y1-1];
}
int calc2(int x1,int y1,int x2,int y2){
return pref2[x2][y2]-pref2[x2][y1-1]-pref2[x1-1][y2]+pref2[x1-1][y1-1];
}
int main()
{
int n,m;
scanf("%d%d",&n,&m);
for(int i = 1;i<=n;i++){
for(int j = 1;j<=m;j++){
char c;
scanf(" %c",&c);
a[i][j] = (c == '1');
}
}
for(int i = 1;i<=n;i++){
for(int j = 1;j<=m;j++){
pref[i][j] = pref[i-1][j]+pref[i][j-1]-pref[i-1][j-1]+a[i][j];
}
}
int ans = 1;
for(int p = n;p>=1;p--){
int lo = 1;
int hi = m;
int as = -1;
while(lo<=hi){
int mid = (lo+hi)/2;
int x = p;
int y = mid;
bool f = true;
for(int i = 1;i<=n;i++)
for(int j = 1;j<=m;j++) pref2[i][j] = 0;
for(int i = 1;i<=n;i++){
for(int j = 1;j<=m;j++){
// if(a[i][j]!=1) continue;
pref2[i][j] = pref2[i-1][j]+pref2[i][j-1]-pref2[i-1][j-1];
if(i+x-1<=n && j+y-1<=m){
if(calc1(i,j,i+x-1,j+y-1) == mid){
pref2[i][j] = pref2[i-1][j]+pref2[i][j-1]-pref2[i-1][j-1]+1;
}
}
if(a[i][j] == 0) continue;
int x1 = i-x+1;
int y1 = j-y+1;
x1 = max(1,x1);
y1 = max(1,y1);
if(calc2(x1,y1,i,j) == 0){
f = false;
break;
}
}
}
if(f){
// F = true;
// break;
lo = mid+1;
as = mid;
continue;
}
swap(x,y);
f = true;
for(int i = 1;i<=n;i++)
for(int j = 1;j<=m;j++) pref2[i][j] = 0;
for(int i = 1;i<=n;i++){
for(int j = 1;j<=m;j++){
// if(a[i][j]!=1) continue;
pref2[i][j] = pref2[i-1][j]+pref2[i][j-1]-pref2[i-1][j-1];
if(i+x-1<=n && j+y-1<=m){
if(calc1(i,j,i+x-1,j+y-1) == mid){
pref2[i][j] = pref2[i-1][j]+pref2[i][j-1]-pref2[i-1][j-1]+1;
}
}
if(a[i][j] == 0) continue;
int x1 = i-x+1;
int y1 = j-y+1;
x1 = max(1,x1);
y1 = max(1,y1);
if(calc2(x1,y1,i,j) == 0){
f = false;
break;
}
}
}
if(f){
// F = true;
// break;
lo = mid+1;
as = mid;
continue;
}
hi = mid-1;
}
if(as == -1) continue;
ans = max(ans,as*p);
}
cout<<ans<<endl;
return 0;
}
Compilation message
bomb.cpp: In function 'int main()':
bomb.cpp:17:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d",&n,&m);
~~~~~^~~~~~~~~~~~~~
bomb.cpp:21:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf(" %c",&c);
~~~~~^~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
2 ms |
764 KB |
Output isn't correct |
3 |
Incorrect |
512 ms |
30620 KB |
Output isn't correct |
4 |
Incorrect |
511 ms |
30656 KB |
Output isn't correct |
5 |
Correct |
2 ms |
30656 KB |
Output is correct |
6 |
Correct |
2 ms |
30656 KB |
Output is correct |
7 |
Incorrect |
2 ms |
30656 KB |
Output isn't correct |
8 |
Incorrect |
2 ms |
30656 KB |
Output isn't correct |
9 |
Incorrect |
2 ms |
30656 KB |
Output isn't correct |
10 |
Incorrect |
2 ms |
30656 KB |
Output isn't correct |
11 |
Incorrect |
2 ms |
30656 KB |
Output isn't correct |
12 |
Correct |
2 ms |
30656 KB |
Output is correct |
13 |
Correct |
2 ms |
30656 KB |
Output is correct |
14 |
Correct |
2 ms |
30656 KB |
Output is correct |
15 |
Incorrect |
2 ms |
30656 KB |
Output isn't correct |
16 |
Incorrect |
2 ms |
30656 KB |
Output isn't correct |
17 |
Incorrect |
6 ms |
30656 KB |
Output isn't correct |
18 |
Incorrect |
9 ms |
30656 KB |
Output isn't correct |
19 |
Incorrect |
20 ms |
30656 KB |
Output isn't correct |
20 |
Incorrect |
20 ms |
30656 KB |
Output isn't correct |
21 |
Incorrect |
10 ms |
30656 KB |
Output isn't correct |
22 |
Incorrect |
16 ms |
30656 KB |
Output isn't correct |
23 |
Incorrect |
30 ms |
30656 KB |
Output isn't correct |
24 |
Incorrect |
15 ms |
30656 KB |
Output isn't correct |
25 |
Incorrect |
23 ms |
30656 KB |
Output isn't correct |
26 |
Incorrect |
10 ms |
30656 KB |
Output isn't correct |
27 |
Correct |
197 ms |
30656 KB |
Output is correct |
28 |
Execution timed out |
1071 ms |
30656 KB |
Time limit exceeded |
29 |
Incorrect |
917 ms |
30656 KB |
Output isn't correct |
30 |
Execution timed out |
1080 ms |
30656 KB |
Time limit exceeded |
31 |
Execution timed out |
1070 ms |
30656 KB |
Time limit exceeded |
32 |
Execution timed out |
1086 ms |
30656 KB |
Time limit exceeded |
33 |
Execution timed out |
1092 ms |
30656 KB |
Time limit exceeded |
34 |
Execution timed out |
1089 ms |
30656 KB |
Time limit exceeded |
35 |
Execution timed out |
1081 ms |
30656 KB |
Time limit exceeded |
36 |
Incorrect |
764 ms |
30656 KB |
Output isn't correct |
37 |
Incorrect |
2 ms |
30656 KB |
Output isn't correct |
38 |
Execution timed out |
1078 ms |
79480 KB |
Time limit exceeded |
39 |
Incorrect |
2 ms |
79480 KB |
Output isn't correct |
40 |
Execution timed out |
1087 ms |
79480 KB |
Time limit exceeded |
41 |
Incorrect |
2 ms |
79480 KB |
Output isn't correct |
42 |
Incorrect |
15 ms |
79480 KB |
Output isn't correct |
43 |
Execution timed out |
1086 ms |
80144 KB |
Time limit exceeded |
44 |
Execution timed out |
1077 ms |
80144 KB |
Time limit exceeded |
45 |
Execution timed out |
1089 ms |
80276 KB |
Time limit exceeded |
46 |
Execution timed out |
1091 ms |
80276 KB |
Time limit exceeded |
47 |
Execution timed out |
1087 ms |
80276 KB |
Time limit exceeded |
48 |
Execution timed out |
1079 ms |
80276 KB |
Time limit exceeded |
49 |
Execution timed out |
1085 ms |
80276 KB |
Time limit exceeded |
50 |
Execution timed out |
1082 ms |
80276 KB |
Time limit exceeded |
51 |
Execution timed out |
1084 ms |
80276 KB |
Time limit exceeded |
52 |
Execution timed out |
1084 ms |
80276 KB |
Time limit exceeded |
53 |
Execution timed out |
1086 ms |
80276 KB |
Time limit exceeded |
54 |
Execution timed out |
1082 ms |
80276 KB |
Time limit exceeded |
55 |
Execution timed out |
1069 ms |
80292 KB |
Time limit exceeded |
56 |
Execution timed out |
1069 ms |
80292 KB |
Time limit exceeded |
57 |
Execution timed out |
1080 ms |
80292 KB |
Time limit exceeded |
58 |
Execution timed out |
1085 ms |
80292 KB |
Time limit exceeded |
59 |
Execution timed out |
1094 ms |
80584 KB |
Time limit exceeded |
60 |
Execution timed out |
1077 ms |
84272 KB |
Time limit exceeded |
61 |
Execution timed out |
1079 ms |
86312 KB |
Time limit exceeded |
62 |
Execution timed out |
1072 ms |
86416 KB |
Time limit exceeded |
63 |
Execution timed out |
1078 ms |
86416 KB |
Time limit exceeded |
64 |
Execution timed out |
1080 ms |
86416 KB |
Time limit exceeded |
65 |
Execution timed out |
1079 ms |
86416 KB |
Time limit exceeded |
66 |
Execution timed out |
1055 ms |
86480 KB |
Time limit exceeded |
67 |
Execution timed out |
1074 ms |
86480 KB |
Time limit exceeded |
68 |
Execution timed out |
1077 ms |
86480 KB |
Time limit exceeded |
69 |
Execution timed out |
1085 ms |
86480 KB |
Time limit exceeded |
70 |
Execution timed out |
1081 ms |
86480 KB |
Time limit exceeded |
71 |
Execution timed out |
1075 ms |
86480 KB |
Time limit exceeded |
72 |
Execution timed out |
1074 ms |
86480 KB |
Time limit exceeded |
73 |
Execution timed out |
1084 ms |
86480 KB |
Time limit exceeded |
74 |
Execution timed out |
1089 ms |
86480 KB |
Time limit exceeded |
75 |
Execution timed out |
1087 ms |
86480 KB |
Time limit exceeded |
76 |
Execution timed out |
1081 ms |
86504 KB |
Time limit exceeded |
77 |
Execution timed out |
1071 ms |
86504 KB |
Time limit exceeded |
78 |
Execution timed out |
1085 ms |
86504 KB |
Time limit exceeded |
79 |
Execution timed out |
1076 ms |
87780 KB |
Time limit exceeded |
80 |
Execution timed out |
1083 ms |
91520 KB |
Time limit exceeded |
81 |
Execution timed out |
1084 ms |
91520 KB |
Time limit exceeded |
82 |
Execution timed out |
1081 ms |
91632 KB |
Time limit exceeded |
83 |
Execution timed out |
1083 ms |
91632 KB |
Time limit exceeded |
84 |
Execution timed out |
1087 ms |
91632 KB |
Time limit exceeded |
85 |
Execution timed out |
1090 ms |
91632 KB |
Time limit exceeded |
86 |
Execution timed out |
1087 ms |
91632 KB |
Time limit exceeded |
87 |
Execution timed out |
1086 ms |
91692 KB |
Time limit exceeded |
88 |
Execution timed out |
1089 ms |
91692 KB |
Time limit exceeded |
89 |
Execution timed out |
1086 ms |
91692 KB |
Time limit exceeded |
90 |
Execution timed out |
1077 ms |
91692 KB |
Time limit exceeded |
91 |
Execution timed out |
1087 ms |
91692 KB |
Time limit exceeded |
92 |
Execution timed out |
1073 ms |
91692 KB |
Time limit exceeded |
93 |
Execution timed out |
1082 ms |
94436 KB |
Time limit exceeded |
94 |
Execution timed out |
1086 ms |
94436 KB |
Time limit exceeded |
95 |
Execution timed out |
1089 ms |
94436 KB |
Time limit exceeded |
96 |
Execution timed out |
1078 ms |
94436 KB |
Time limit exceeded |
97 |
Execution timed out |
1093 ms |
94436 KB |
Time limit exceeded |
98 |
Execution timed out |
1074 ms |
94436 KB |
Time limit exceeded |
99 |
Execution timed out |
1087 ms |
94480 KB |
Time limit exceeded |
100 |
Execution timed out |
1072 ms |
94568 KB |
Time limit exceeded |