# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1118850 |
2024-11-26T09:30:41 Z |
Younis_Dwai |
Bomb (IZhO17_bomb) |
C++14 |
|
661 ms |
11616 KB |
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include <bits/stdc++.h>
#define endl "\n"
#define F first
#define S second
#define pb push_back
//#define int long long
#define in insert
//#define mid (l+r)/2
#define in insert
using namespace std;
const int N=2505;
char b[N][N];
int n,m,pref[505][505],d[505][505];
void init(){
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]+bool(b[i][j]=='1');
}
}
return ;
}
int query(int x , int y , int x1 , int y1){
return pref[x1][y1]-pref[x1][y-1]-pref[x-1][y1]+pref[x-1][y-1];
}
int Query(int x , int y , int x1 , int y1){
return d[x1][y1]-d[x1][y-1]-d[x-1][y1]+d[x-1][y-1];
}
bool ok(int h , int w){
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
d[i][j]=0;
}
}
for(int i=1;i+h-1<=n;i++){
for(int j=1;j+w-1<=m;j++){
if(query(i,j,i+h-1,j+w-1)==h*w){
d[i][j]=1;
}
}
}
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
d[i][j]=d[i-1][j]+d[i][j-1]-d[i-1][j-1]+d[i][j];
}
}
bool can=1;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
if(b[i][j]=='1'){
int i1=max(1,i-h+1),j1=max(1,j-w+1);
if(Query(i1,j1,i,j)==0) can=0;
}
}
}
return can;
}
int32_t main(){
ios::sync_with_stdio(false);cin.tie(nullptr);
cin>>n>>m;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
cin>>b[i][j];
}
}
if(n<=350 && m<=350 && n!=1 && m!=1){
int mx=0;
init();
for(int i=1;i<=n;i++){
int l=1,r=n,mid=(l+r+1)/2;
while(l<r){
if(ok(i,mid)) l=mid;
else r=mid-1;
mid=(l+r+1)/2;
}
if(ok(i,mid)) mx=max(mx,i*mid);
}
cout<<mx;
}
else{
int h=n,w=m;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
if(b[i][j]=='1'){
int cnt=1;
while(j+1<=m && b[i][j+1]=='1'){
++cnt;
++j;
}
w=min(w,cnt);
}
}
}
for(int j=1;j<=m;j++){
for(int i=1;i<=n;i++){
if(b[i][j]=='1'){
int cnt=1;
while(i+1<=n && b[i+1][j]=='1'){
++i;
++cnt;
}
h=min(h,cnt);
}
}
}
cout<<h*w;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
592 KB |
Output is correct |
3 |
Correct |
7 ms |
6480 KB |
Output is correct |
4 |
Correct |
5 ms |
6460 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
2 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
2 ms |
592 KB |
Output is correct |
9 |
Correct |
1 ms |
592 KB |
Output is correct |
10 |
Correct |
1 ms |
592 KB |
Output is correct |
11 |
Correct |
1 ms |
592 KB |
Output is correct |
12 |
Correct |
1 ms |
504 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
2 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
592 KB |
Output is correct |
16 |
Correct |
2 ms |
464 KB |
Output is correct |
17 |
Correct |
6 ms |
728 KB |
Output is correct |
18 |
Correct |
5 ms |
848 KB |
Output is correct |
19 |
Correct |
10 ms |
1084 KB |
Output is correct |
20 |
Correct |
15 ms |
848 KB |
Output is correct |
21 |
Correct |
4 ms |
732 KB |
Output is correct |
22 |
Correct |
10 ms |
848 KB |
Output is correct |
23 |
Correct |
19 ms |
1104 KB |
Output is correct |
24 |
Correct |
10 ms |
864 KB |
Output is correct |
25 |
Correct |
22 ms |
1104 KB |
Output is correct |
26 |
Correct |
27 ms |
1132 KB |
Output is correct |
27 |
Correct |
661 ms |
2436 KB |
Output is correct |
28 |
Incorrect |
3 ms |
1272 KB |
Output isn't correct |
29 |
Incorrect |
3 ms |
1568 KB |
Output isn't correct |
30 |
Incorrect |
6 ms |
1616 KB |
Output isn't correct |
31 |
Incorrect |
4 ms |
1440 KB |
Output isn't correct |
32 |
Incorrect |
3 ms |
1616 KB |
Output isn't correct |
33 |
Incorrect |
5 ms |
1780 KB |
Output isn't correct |
34 |
Incorrect |
2 ms |
1360 KB |
Output isn't correct |
35 |
Incorrect |
4 ms |
1616 KB |
Output isn't correct |
36 |
Correct |
6 ms |
1616 KB |
Output is correct |
37 |
Correct |
1 ms |
592 KB |
Output is correct |
38 |
Correct |
65 ms |
9764 KB |
Output is correct |
39 |
Correct |
1 ms |
592 KB |
Output is correct |
40 |
Incorrect |
10 ms |
3196 KB |
Output isn't correct |
41 |
Correct |
2 ms |
760 KB |
Output is correct |
42 |
Correct |
25 ms |
1104 KB |
Output is correct |
43 |
Correct |
81 ms |
11368 KB |
Output is correct |
44 |
Incorrect |
4 ms |
1616 KB |
Output isn't correct |
45 |
Incorrect |
92 ms |
9688 KB |
Output isn't correct |
46 |
Correct |
92 ms |
9912 KB |
Output is correct |
47 |
Incorrect |
83 ms |
9772 KB |
Output isn't correct |
48 |
Incorrect |
83 ms |
11328 KB |
Output isn't correct |
49 |
Correct |
91 ms |
11396 KB |
Output is correct |
50 |
Incorrect |
70 ms |
11368 KB |
Output isn't correct |
51 |
Incorrect |
69 ms |
11336 KB |
Output isn't correct |
52 |
Incorrect |
78 ms |
9876 KB |
Output isn't correct |
53 |
Incorrect |
91 ms |
9864 KB |
Output isn't correct |
54 |
Incorrect |
69 ms |
11268 KB |
Output isn't correct |
55 |
Incorrect |
89 ms |
11616 KB |
Output isn't correct |
56 |
Correct |
111 ms |
9916 KB |
Output is correct |
57 |
Incorrect |
94 ms |
11452 KB |
Output isn't correct |
58 |
Incorrect |
133 ms |
11432 KB |
Output isn't correct |
59 |
Incorrect |
93 ms |
9784 KB |
Output isn't correct |
60 |
Correct |
71 ms |
9736 KB |
Output is correct |
61 |
Correct |
121 ms |
11240 KB |
Output is correct |
62 |
Correct |
80 ms |
11336 KB |
Output is correct |
63 |
Correct |
87 ms |
9912 KB |
Output is correct |
64 |
Correct |
133 ms |
9800 KB |
Output is correct |
65 |
Incorrect |
103 ms |
9868 KB |
Output isn't correct |
66 |
Incorrect |
76 ms |
11336 KB |
Output isn't correct |
67 |
Incorrect |
96 ms |
9700 KB |
Output isn't correct |
68 |
Incorrect |
101 ms |
11408 KB |
Output isn't correct |
69 |
Incorrect |
116 ms |
9868 KB |
Output isn't correct |
70 |
Incorrect |
48 ms |
8592 KB |
Output isn't correct |
71 |
Incorrect |
78 ms |
9916 KB |
Output isn't correct |
72 |
Incorrect |
102 ms |
9772 KB |
Output isn't correct |
73 |
Incorrect |
95 ms |
11592 KB |
Output isn't correct |
74 |
Incorrect |
90 ms |
11336 KB |
Output isn't correct |
75 |
Incorrect |
101 ms |
11432 KB |
Output isn't correct |
76 |
Incorrect |
89 ms |
9920 KB |
Output isn't correct |
77 |
Incorrect |
132 ms |
11444 KB |
Output isn't correct |
78 |
Incorrect |
102 ms |
11216 KB |
Output isn't correct |
79 |
Incorrect |
95 ms |
9860 KB |
Output isn't correct |
80 |
Incorrect |
83 ms |
11284 KB |
Output isn't correct |
81 |
Incorrect |
76 ms |
9916 KB |
Output isn't correct |
82 |
Incorrect |
69 ms |
11452 KB |
Output isn't correct |
83 |
Incorrect |
99 ms |
11368 KB |
Output isn't correct |
84 |
Incorrect |
79 ms |
9800 KB |
Output isn't correct |
85 |
Incorrect |
73 ms |
9900 KB |
Output isn't correct |
86 |
Incorrect |
71 ms |
9792 KB |
Output isn't correct |
87 |
Incorrect |
118 ms |
9888 KB |
Output isn't correct |
88 |
Incorrect |
85 ms |
11216 KB |
Output isn't correct |
89 |
Incorrect |
86 ms |
9704 KB |
Output isn't correct |
90 |
Incorrect |
46 ms |
7496 KB |
Output isn't correct |
91 |
Incorrect |
84 ms |
9764 KB |
Output isn't correct |
92 |
Incorrect |
69 ms |
11356 KB |
Output isn't correct |
93 |
Incorrect |
87 ms |
9920 KB |
Output isn't correct |
94 |
Incorrect |
113 ms |
9812 KB |
Output isn't correct |
95 |
Incorrect |
94 ms |
11288 KB |
Output isn't correct |
96 |
Incorrect |
95 ms |
11308 KB |
Output isn't correct |
97 |
Incorrect |
74 ms |
9760 KB |
Output isn't correct |
98 |
Incorrect |
92 ms |
11408 KB |
Output isn't correct |
99 |
Incorrect |
78 ms |
9832 KB |
Output isn't correct |
100 |
Incorrect |
79 ms |
11608 KB |
Output isn't correct |