# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
91269 |
2018-12-26T20:01:40 Z |
Vardanyan |
Bomb (IZhO17_bomb) |
C++14 |
|
107 ms |
10300 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<=n;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(l<=r){
int mid = (l+r)/2;
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;
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;
}
else{
pref2[i][j] = pref2[i-1][j]+pref2[i][j-1]-pref2[i-1][j-1];
}
}
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){
ans = mid;
l = mid+1;
}
else r = mid-1;
}
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: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 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Correct |
2 ms |
768 KB |
Output is correct |
3 |
Incorrect |
2 ms |
768 KB |
Output isn't correct |
4 |
Incorrect |
2 ms |
768 KB |
Output isn't correct |
5 |
Incorrect |
2 ms |
768 KB |
Output isn't correct |
6 |
Incorrect |
2 ms |
768 KB |
Output isn't correct |
7 |
Incorrect |
2 ms |
768 KB |
Output isn't correct |
8 |
Incorrect |
2 ms |
768 KB |
Output isn't correct |
9 |
Incorrect |
2 ms |
768 KB |
Output isn't correct |
10 |
Incorrect |
2 ms |
768 KB |
Output isn't correct |
11 |
Incorrect |
2 ms |
820 KB |
Output isn't correct |
12 |
Correct |
2 ms |
820 KB |
Output is correct |
13 |
Incorrect |
2 ms |
820 KB |
Output isn't correct |
14 |
Correct |
2 ms |
820 KB |
Output is correct |
15 |
Incorrect |
2 ms |
820 KB |
Output isn't correct |
16 |
Incorrect |
2 ms |
820 KB |
Output isn't correct |
17 |
Incorrect |
3 ms |
1448 KB |
Output isn't correct |
18 |
Correct |
3 ms |
1584 KB |
Output is correct |
19 |
Incorrect |
4 ms |
1848 KB |
Output isn't correct |
20 |
Incorrect |
5 ms |
1868 KB |
Output isn't correct |
21 |
Correct |
3 ms |
1868 KB |
Output is correct |
22 |
Incorrect |
3 ms |
1868 KB |
Output isn't correct |
23 |
Incorrect |
5 ms |
2036 KB |
Output isn't correct |
24 |
Incorrect |
3 ms |
2036 KB |
Output isn't correct |
25 |
Incorrect |
5 ms |
2056 KB |
Output isn't correct |
26 |
Incorrect |
5 ms |
2068 KB |
Output isn't correct |
27 |
Incorrect |
22 ms |
5280 KB |
Output isn't correct |
28 |
Incorrect |
31 ms |
5564 KB |
Output isn't correct |
29 |
Incorrect |
87 ms |
7264 KB |
Output isn't correct |
30 |
Incorrect |
107 ms |
8668 KB |
Output isn't correct |
31 |
Incorrect |
43 ms |
8668 KB |
Output isn't correct |
32 |
Incorrect |
38 ms |
8668 KB |
Output isn't correct |
33 |
Incorrect |
78 ms |
9668 KB |
Output isn't correct |
34 |
Correct |
35 ms |
9668 KB |
Output is correct |
35 |
Incorrect |
105 ms |
9952 KB |
Output isn't correct |
36 |
Incorrect |
68 ms |
10024 KB |
Output isn't correct |
37 |
Incorrect |
2 ms |
10024 KB |
Output isn't correct |
38 |
Incorrect |
1 ms |
10024 KB |
Output isn't correct |
39 |
Incorrect |
2 ms |
10024 KB |
Output isn't correct |
40 |
Incorrect |
2 ms |
10024 KB |
Output isn't correct |
41 |
Incorrect |
2 ms |
10024 KB |
Output isn't correct |
42 |
Incorrect |
5 ms |
10024 KB |
Output isn't correct |
43 |
Incorrect |
1 ms |
10024 KB |
Output isn't correct |
44 |
Incorrect |
79 ms |
10300 KB |
Output isn't correct |
45 |
Incorrect |
1 ms |
10300 KB |
Output isn't correct |
46 |
Incorrect |
1 ms |
10300 KB |
Output isn't correct |
47 |
Incorrect |
1 ms |
10300 KB |
Output isn't correct |
48 |
Incorrect |
2 ms |
10300 KB |
Output isn't correct |
49 |
Incorrect |
2 ms |
10300 KB |
Output isn't correct |
50 |
Incorrect |
1 ms |
10300 KB |
Output isn't correct |
51 |
Incorrect |
2 ms |
10300 KB |
Output isn't correct |
52 |
Incorrect |
1 ms |
10300 KB |
Output isn't correct |
53 |
Incorrect |
1 ms |
10300 KB |
Output isn't correct |
54 |
Incorrect |
2 ms |
10300 KB |
Output isn't correct |
55 |
Incorrect |
2 ms |
10300 KB |
Output isn't correct |
56 |
Incorrect |
2 ms |
10300 KB |
Output isn't correct |
57 |
Incorrect |
2 ms |
10300 KB |
Output isn't correct |
58 |
Incorrect |
2 ms |
10300 KB |
Output isn't correct |
59 |
Incorrect |
2 ms |
10300 KB |
Output isn't correct |
60 |
Incorrect |
2 ms |
10300 KB |
Output isn't correct |
61 |
Incorrect |
2 ms |
10300 KB |
Output isn't correct |
62 |
Incorrect |
2 ms |
10300 KB |
Output isn't correct |
63 |
Incorrect |
2 ms |
10300 KB |
Output isn't correct |
64 |
Incorrect |
2 ms |
10300 KB |
Output isn't correct |
65 |
Incorrect |
2 ms |
10300 KB |
Output isn't correct |
66 |
Incorrect |
2 ms |
10300 KB |
Output isn't correct |
67 |
Incorrect |
2 ms |
10300 KB |
Output isn't correct |
68 |
Incorrect |
2 ms |
10300 KB |
Output isn't correct |
69 |
Incorrect |
2 ms |
10300 KB |
Output isn't correct |
70 |
Incorrect |
2 ms |
10300 KB |
Output isn't correct |
71 |
Incorrect |
2 ms |
10300 KB |
Output isn't correct |
72 |
Incorrect |
2 ms |
10300 KB |
Output isn't correct |
73 |
Incorrect |
2 ms |
10300 KB |
Output isn't correct |
74 |
Incorrect |
2 ms |
10300 KB |
Output isn't correct |
75 |
Incorrect |
2 ms |
10300 KB |
Output isn't correct |
76 |
Incorrect |
2 ms |
10300 KB |
Output isn't correct |
77 |
Incorrect |
2 ms |
10300 KB |
Output isn't correct |
78 |
Incorrect |
2 ms |
10300 KB |
Output isn't correct |
79 |
Incorrect |
2 ms |
10300 KB |
Output isn't correct |
80 |
Incorrect |
2 ms |
10300 KB |
Output isn't correct |
81 |
Incorrect |
2 ms |
10300 KB |
Output isn't correct |
82 |
Incorrect |
2 ms |
10300 KB |
Output isn't correct |
83 |
Incorrect |
1 ms |
10300 KB |
Output isn't correct |
84 |
Incorrect |
1 ms |
10300 KB |
Output isn't correct |
85 |
Incorrect |
2 ms |
10300 KB |
Output isn't correct |
86 |
Incorrect |
2 ms |
10300 KB |
Output isn't correct |
87 |
Incorrect |
2 ms |
10300 KB |
Output isn't correct |
88 |
Incorrect |
2 ms |
10300 KB |
Output isn't correct |
89 |
Incorrect |
1 ms |
10300 KB |
Output isn't correct |
90 |
Incorrect |
2 ms |
10300 KB |
Output isn't correct |
91 |
Incorrect |
2 ms |
10300 KB |
Output isn't correct |
92 |
Incorrect |
2 ms |
10300 KB |
Output isn't correct |
93 |
Incorrect |
2 ms |
10300 KB |
Output isn't correct |
94 |
Incorrect |
2 ms |
10300 KB |
Output isn't correct |
95 |
Incorrect |
2 ms |
10300 KB |
Output isn't correct |
96 |
Incorrect |
2 ms |
10300 KB |
Output isn't correct |
97 |
Incorrect |
2 ms |
10300 KB |
Output isn't correct |
98 |
Incorrect |
2 ms |
10300 KB |
Output isn't correct |
99 |
Incorrect |
2 ms |
10300 KB |
Output isn't correct |
100 |
Incorrect |
2 ms |
10300 KB |
Output isn't correct |