# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
91420 |
2018-12-27T12:22:29 Z |
Vardanyan |
Bomb (IZhO17_bomb) |
C++14 |
|
1000 ms |
10024 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);
if(n>450 || m>450) return 0;
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 l = 1;
int r = n*m;
int ans = 1;
while(r>=1){
int mid = r;
bool F = false;
for(int q = 1;q<=sqrt(mid);q++){
if(mid%q) continue;
int x = mid/q;
int y = q;
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;
}
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;
}
}
if(F){
ans = mid;
break;
}
r--;
}
cout<<ans<<endl;
return 0;
}
Compilation message
bomb.cpp: In function 'int main()':
bomb.cpp:31:9: warning: unused variable 'l' [-Wunused-variable]
int l = 1;
^
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:22: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 |
Correct |
2 ms |
632 KB |
Output is correct |
3 |
Incorrect |
2 ms |
632 KB |
Output isn't correct |
4 |
Incorrect |
2 ms |
632 KB |
Output isn't correct |
5 |
Incorrect |
2 ms |
632 KB |
Output isn't correct |
6 |
Incorrect |
2 ms |
632 KB |
Output isn't correct |
7 |
Correct |
2 ms |
632 KB |
Output is correct |
8 |
Correct |
4 ms |
816 KB |
Output is correct |
9 |
Correct |
4 ms |
896 KB |
Output is correct |
10 |
Correct |
2 ms |
896 KB |
Output is correct |
11 |
Correct |
4 ms |
896 KB |
Output is correct |
12 |
Correct |
2 ms |
928 KB |
Output is correct |
13 |
Correct |
2 ms |
928 KB |
Output is correct |
14 |
Correct |
2 ms |
928 KB |
Output is correct |
15 |
Correct |
3 ms |
928 KB |
Output is correct |
16 |
Correct |
3 ms |
928 KB |
Output is correct |
17 |
Correct |
163 ms |
1604 KB |
Output is correct |
18 |
Correct |
312 ms |
1612 KB |
Output is correct |
19 |
Correct |
875 ms |
1956 KB |
Output is correct |
20 |
Correct |
982 ms |
1956 KB |
Output is correct |
21 |
Correct |
442 ms |
1956 KB |
Output is correct |
22 |
Correct |
847 ms |
1956 KB |
Output is correct |
23 |
Execution timed out |
1082 ms |
2040 KB |
Time limit exceeded |
24 |
Correct |
542 ms |
2040 KB |
Output is correct |
25 |
Execution timed out |
1084 ms |
2056 KB |
Time limit exceeded |
26 |
Correct |
611 ms |
2128 KB |
Output is correct |
27 |
Execution timed out |
1076 ms |
5280 KB |
Time limit exceeded |
28 |
Execution timed out |
1077 ms |
5744 KB |
Time limit exceeded |
29 |
Execution timed out |
1082 ms |
7140 KB |
Time limit exceeded |
30 |
Execution timed out |
1073 ms |
8672 KB |
Time limit exceeded |
31 |
Execution timed out |
1082 ms |
8672 KB |
Time limit exceeded |
32 |
Execution timed out |
1072 ms |
8672 KB |
Time limit exceeded |
33 |
Execution timed out |
1078 ms |
9540 KB |
Time limit exceeded |
34 |
Execution timed out |
1076 ms |
9540 KB |
Time limit exceeded |
35 |
Execution timed out |
1085 ms |
9824 KB |
Time limit exceeded |
36 |
Execution timed out |
1090 ms |
10024 KB |
Time limit exceeded |
37 |
Correct |
3 ms |
10024 KB |
Output is correct |
38 |
Incorrect |
1 ms |
10024 KB |
Output isn't correct |
39 |
Correct |
3 ms |
10024 KB |
Output is correct |
40 |
Incorrect |
1 ms |
10024 KB |
Output isn't correct |
41 |
Correct |
3 ms |
10024 KB |
Output is correct |
42 |
Correct |
785 ms |
10024 KB |
Output is correct |
43 |
Incorrect |
2 ms |
10024 KB |
Output isn't correct |
44 |
Execution timed out |
1076 ms |
10024 KB |
Time limit exceeded |
45 |
Incorrect |
2 ms |
10024 KB |
Output isn't correct |
46 |
Incorrect |
2 ms |
10024 KB |
Output isn't correct |
47 |
Incorrect |
2 ms |
10024 KB |
Output isn't correct |
48 |
Incorrect |
2 ms |
10024 KB |
Output isn't correct |
49 |
Incorrect |
1 ms |
10024 KB |
Output isn't correct |
50 |
Incorrect |
2 ms |
10024 KB |
Output isn't correct |
51 |
Incorrect |
1 ms |
10024 KB |
Output isn't correct |
52 |
Incorrect |
2 ms |
10024 KB |
Output isn't correct |
53 |
Incorrect |
2 ms |
10024 KB |
Output isn't correct |
54 |
Incorrect |
1 ms |
10024 KB |
Output isn't correct |
55 |
Incorrect |
1 ms |
10024 KB |
Output isn't correct |
56 |
Incorrect |
1 ms |
10024 KB |
Output isn't correct |
57 |
Incorrect |
1 ms |
10024 KB |
Output isn't correct |
58 |
Incorrect |
1 ms |
10024 KB |
Output isn't correct |
59 |
Incorrect |
1 ms |
10024 KB |
Output isn't correct |
60 |
Incorrect |
2 ms |
10024 KB |
Output isn't correct |
61 |
Incorrect |
1 ms |
10024 KB |
Output isn't correct |
62 |
Incorrect |
1 ms |
10024 KB |
Output isn't correct |
63 |
Incorrect |
2 ms |
10024 KB |
Output isn't correct |
64 |
Incorrect |
2 ms |
10024 KB |
Output isn't correct |
65 |
Incorrect |
2 ms |
10024 KB |
Output isn't correct |
66 |
Incorrect |
1 ms |
10024 KB |
Output isn't correct |
67 |
Incorrect |
2 ms |
10024 KB |
Output isn't correct |
68 |
Incorrect |
2 ms |
10024 KB |
Output isn't correct |
69 |
Incorrect |
2 ms |
10024 KB |
Output isn't correct |
70 |
Incorrect |
2 ms |
10024 KB |
Output isn't correct |
71 |
Incorrect |
2 ms |
10024 KB |
Output isn't correct |
72 |
Incorrect |
2 ms |
10024 KB |
Output isn't correct |
73 |
Incorrect |
2 ms |
10024 KB |
Output isn't correct |
74 |
Incorrect |
2 ms |
10024 KB |
Output isn't correct |
75 |
Incorrect |
2 ms |
10024 KB |
Output isn't correct |
76 |
Incorrect |
2 ms |
10024 KB |
Output isn't correct |
77 |
Incorrect |
2 ms |
10024 KB |
Output isn't correct |
78 |
Incorrect |
2 ms |
10024 KB |
Output isn't correct |
79 |
Incorrect |
2 ms |
10024 KB |
Output isn't correct |
80 |
Incorrect |
2 ms |
10024 KB |
Output isn't correct |
81 |
Incorrect |
2 ms |
10024 KB |
Output isn't correct |
82 |
Incorrect |
2 ms |
10024 KB |
Output isn't correct |
83 |
Incorrect |
2 ms |
10024 KB |
Output isn't correct |
84 |
Incorrect |
2 ms |
10024 KB |
Output isn't correct |
85 |
Incorrect |
2 ms |
10024 KB |
Output isn't correct |
86 |
Incorrect |
2 ms |
10024 KB |
Output isn't correct |
87 |
Incorrect |
2 ms |
10024 KB |
Output isn't correct |
88 |
Incorrect |
2 ms |
10024 KB |
Output isn't correct |
89 |
Incorrect |
2 ms |
10024 KB |
Output isn't correct |
90 |
Incorrect |
2 ms |
10024 KB |
Output isn't correct |
91 |
Incorrect |
2 ms |
10024 KB |
Output isn't correct |
92 |
Incorrect |
2 ms |
10024 KB |
Output isn't correct |
93 |
Incorrect |
2 ms |
10024 KB |
Output isn't correct |
94 |
Incorrect |
2 ms |
10024 KB |
Output isn't correct |
95 |
Incorrect |
2 ms |
10024 KB |
Output isn't correct |
96 |
Incorrect |
1 ms |
10024 KB |
Output isn't correct |
97 |
Incorrect |
1 ms |
10024 KB |
Output isn't correct |
98 |
Incorrect |
2 ms |
10024 KB |
Output isn't correct |
99 |
Incorrect |
1 ms |
10024 KB |
Output isn't correct |
100 |
Incorrect |
2 ms |
10024 KB |
Output isn't correct |