# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
167414 |
2019-12-08T10:14:56 Z |
GioChkhaidze |
Bomb (IZhO17_bomb) |
C++14 |
|
1000 ms |
131076 KB |
#include <bits/stdc++.h>
#define Tree int h,int l,int r
#define Left 2*h,l,(l+r)/2
#define Right 2*h+1,(l+r)/2+1,r
#define F first
#define S second
using namespace std;
const int N=2505;
int n,m,width=1e9,length=1e9,last,D[N][N];
bool f[N][N];
string s[N],S;
vector < pair < int , pair < int , int > > > v;
inline bool check(int x,int y) {
for (int i=0; i<n; i++)
for (int j=0; j<m; j++)
if (s[i][j]=='1') f[i][j]=1;
else f[i][j]=0;
for (int i=0; i<n; i++)
for (int j=0; j<m; j++)
if (s[i][j]=='1')
if (i+x-1<n && j+y-1<m) {
if (D[i+x][j+y]-D[i][j+y]-D[i+x][j]+D[i][j]!=0 && !f[i][j]) continue;
if (D[i+x][j+y]-D[i][j+y]-D[i+x][j]+D[i][j]!=0) return 0;
for (int k1=i; k1<i+x; k1++)
for (int k2=j; k2<j+y; k2++)
f[k1][k2]=0;
}
return 1;
}
main () {
scanf("%d%d",&n,&m);
getline(cin,S);
for (int i=0; i<n; i++)
getline(cin,s[i]);
for (int i=0; i<n; i++)
for (int j=0; j<m; j++)
D[i+1][j+1]=D[i][j+1]+D[i+1][j]-D[i][j]+(s[i][j]=='0');
for (int i=0; i<n; i++) {
last=m;
for (int j=m-1; j>=0; j--) {
if (s[i][j]=='0' && last-1!=j)
if (width>last-j-1) width=last-j-1;
if (s[i][j]=='0') last=j;
}
if (last)
if (last<width) width=last;
}
for (int j=0; j<m; j++) {
last=n;
for (int i=n-1; i>=0; i--) {
if (s[i][j]=='0' && last-1!=i)
if (length>last-i-1) length=last-i-1;
if (s[i][j]=='0') last=i;
}
if (last)
if (last<length) length=last;
}
if (width==1e9 || length==1e9) { cout<<0<<endl; return 0; }
for (int i=1; i<=length; i++)
for (int j=1; j<=width; j++)
v.push_back({i*j,{i,j}});
sort(v.begin(),v.end());
for (int i=v.size()-1; i>=0; i--) {
if (check(v[i].S.F,v[i].S.S)) {
cout<<v[i].F<<endl;
return 0;
}
}
}
Compilation message
bomb.cpp:33:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
main () {
^
bomb.cpp: In function 'int main()':
bomb.cpp:34:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d",&n,&m);
~~~~~^~~~~~~~~~~~~~
# |
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 |
20 ms |
16632 KB |
Output is correct |
4 |
Correct |
22 ms |
16632 KB |
Output is correct |
5 |
Correct |
21 ms |
504 KB |
Output is correct |
6 |
Correct |
2 ms |
504 KB |
Output is correct |
7 |
Correct |
2 ms |
504 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 |
504 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 |
3 ms |
888 KB |
Output is correct |
18 |
Correct |
3 ms |
888 KB |
Output is correct |
19 |
Correct |
6 ms |
1016 KB |
Output is correct |
20 |
Correct |
6 ms |
1016 KB |
Output is correct |
21 |
Correct |
3 ms |
760 KB |
Output is correct |
22 |
Correct |
3 ms |
1016 KB |
Output is correct |
23 |
Correct |
9 ms |
1156 KB |
Output is correct |
24 |
Correct |
6 ms |
1016 KB |
Output is correct |
25 |
Correct |
44 ms |
1144 KB |
Output is correct |
26 |
Correct |
5 ms |
1144 KB |
Output is correct |
27 |
Correct |
10 ms |
2808 KB |
Output is correct |
28 |
Correct |
13 ms |
2936 KB |
Output is correct |
29 |
Incorrect |
171 ms |
3960 KB |
Output isn't correct |
30 |
Execution timed out |
1076 ms |
4664 KB |
Time limit exceeded |
31 |
Execution timed out |
1084 ms |
3768 KB |
Time limit exceeded |
32 |
Execution timed out |
1072 ms |
4180 KB |
Time limit exceeded |
33 |
Execution timed out |
1085 ms |
4852 KB |
Time limit exceeded |
34 |
Correct |
12 ms |
3192 KB |
Output is correct |
35 |
Correct |
851 ms |
4564 KB |
Output is correct |
36 |
Correct |
133 ms |
4728 KB |
Output is correct |
37 |
Correct |
2 ms |
504 KB |
Output is correct |
38 |
Runtime error |
611 ms |
131076 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
39 |
Correct |
3 ms |
504 KB |
Output is correct |
40 |
Execution timed out |
1065 ms |
12388 KB |
Time limit exceeded |
41 |
Correct |
2 ms |
504 KB |
Output is correct |
42 |
Correct |
203 ms |
1348 KB |
Output is correct |
43 |
Execution timed out |
1087 ms |
49760 KB |
Time limit exceeded |
44 |
Execution timed out |
1076 ms |
5228 KB |
Time limit exceeded |
45 |
Execution timed out |
1071 ms |
64712 KB |
Time limit exceeded |
46 |
Correct |
468 ms |
46712 KB |
Output is correct |
47 |
Execution timed out |
1064 ms |
65396 KB |
Time limit exceeded |
48 |
Execution timed out |
1087 ms |
46692 KB |
Time limit exceeded |
49 |
Correct |
595 ms |
46712 KB |
Output is correct |
50 |
Execution timed out |
1083 ms |
46916 KB |
Time limit exceeded |
51 |
Execution timed out |
1072 ms |
46764 KB |
Time limit exceeded |
52 |
Execution timed out |
1077 ms |
46712 KB |
Time limit exceeded |
53 |
Execution timed out |
1080 ms |
46700 KB |
Time limit exceeded |
54 |
Execution timed out |
1083 ms |
46936 KB |
Time limit exceeded |
55 |
Execution timed out |
1067 ms |
46712 KB |
Time limit exceeded |
56 |
Correct |
501 ms |
48192 KB |
Output is correct |
57 |
Execution timed out |
1077 ms |
46784 KB |
Time limit exceeded |
58 |
Execution timed out |
1077 ms |
46988 KB |
Time limit exceeded |
59 |
Execution timed out |
1082 ms |
46840 KB |
Time limit exceeded |
60 |
Execution timed out |
1071 ms |
46716 KB |
Time limit exceeded |
61 |
Execution timed out |
1080 ms |
46832 KB |
Time limit exceeded |
62 |
Execution timed out |
1083 ms |
48108 KB |
Time limit exceeded |
63 |
Execution timed out |
1082 ms |
65480 KB |
Time limit exceeded |
64 |
Correct |
741 ms |
47440 KB |
Output is correct |
65 |
Execution timed out |
1080 ms |
46712 KB |
Time limit exceeded |
66 |
Execution timed out |
1084 ms |
47040 KB |
Time limit exceeded |
67 |
Execution timed out |
1081 ms |
46904 KB |
Time limit exceeded |
68 |
Execution timed out |
1079 ms |
47048 KB |
Time limit exceeded |
69 |
Execution timed out |
1076 ms |
46724 KB |
Time limit exceeded |
70 |
Execution timed out |
1086 ms |
38120 KB |
Time limit exceeded |
71 |
Execution timed out |
1069 ms |
50876 KB |
Time limit exceeded |
72 |
Execution timed out |
1080 ms |
53196 KB |
Time limit exceeded |
73 |
Execution timed out |
1063 ms |
53632 KB |
Time limit exceeded |
74 |
Execution timed out |
1071 ms |
53160 KB |
Time limit exceeded |
75 |
Execution timed out |
1083 ms |
53576 KB |
Time limit exceeded |
76 |
Execution timed out |
1076 ms |
54088 KB |
Time limit exceeded |
77 |
Execution timed out |
1064 ms |
54428 KB |
Time limit exceeded |
78 |
Execution timed out |
1082 ms |
54172 KB |
Time limit exceeded |
79 |
Execution timed out |
1065 ms |
46736 KB |
Time limit exceeded |
80 |
Execution timed out |
1067 ms |
46736 KB |
Time limit exceeded |
81 |
Execution timed out |
1084 ms |
47432 KB |
Time limit exceeded |
82 |
Execution timed out |
1084 ms |
54932 KB |
Time limit exceeded |
83 |
Execution timed out |
1090 ms |
54856 KB |
Time limit exceeded |
84 |
Execution timed out |
1057 ms |
46840 KB |
Time limit exceeded |
85 |
Execution timed out |
1076 ms |
49624 KB |
Time limit exceeded |
86 |
Execution timed out |
1075 ms |
46800 KB |
Time limit exceeded |
87 |
Execution timed out |
1085 ms |
49380 KB |
Time limit exceeded |
88 |
Execution timed out |
1086 ms |
54872 KB |
Time limit exceeded |
89 |
Execution timed out |
1079 ms |
47980 KB |
Time limit exceeded |
90 |
Execution timed out |
1088 ms |
39020 KB |
Time limit exceeded |
91 |
Execution timed out |
1073 ms |
49056 KB |
Time limit exceeded |
92 |
Execution timed out |
1058 ms |
48420 KB |
Time limit exceeded |
93 |
Execution timed out |
1092 ms |
46712 KB |
Time limit exceeded |
94 |
Execution timed out |
1086 ms |
47876 KB |
Time limit exceeded |
95 |
Execution timed out |
1091 ms |
54856 KB |
Time limit exceeded |
96 |
Execution timed out |
1068 ms |
54872 KB |
Time limit exceeded |
97 |
Execution timed out |
1087 ms |
46792 KB |
Time limit exceeded |
98 |
Execution timed out |
1087 ms |
54924 KB |
Time limit exceeded |
99 |
Execution timed out |
1082 ms |
47848 KB |
Time limit exceeded |
100 |
Execution timed out |
1080 ms |
46784 KB |
Time limit exceeded |