Submission #1118818

# Submission time Handle Problem Language Result Execution time Memory
1118818 2024-11-26T08:10:43 Z Younis_Dwai Bomb (IZhO17_bomb) C++14
41 / 100
126 ms 12776 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[205][205],d[205][205];
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<=200 && m<=200){
       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 Incorrect 1 ms 2384 KB Output isn't correct
2 Correct 1 ms 2520 KB Output is correct
3 Correct 2 ms 6748 KB Output is correct
4 Correct 2 ms 6636 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2384 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 472 KB Output is correct
10 Correct 1 ms 464 KB Output is correct
11 Correct 2 ms 2640 KB Output is correct
12 Correct 2 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 8 ms 592 KB Output is correct
18 Correct 5 ms 740 KB Output is correct
19 Correct 13 ms 876 KB Output is correct
20 Correct 10 ms 860 KB Output is correct
21 Correct 4 ms 604 KB Output is correct
22 Correct 8 ms 604 KB Output is correct
23 Correct 15 ms 1020 KB Output is correct
24 Correct 8 ms 760 KB Output is correct
25 Correct 19 ms 908 KB Output is correct
26 Correct 24 ms 860 KB Output is correct
27 Correct 2 ms 1272 KB Output is correct
28 Incorrect 3 ms 1212 KB Output isn't correct
29 Incorrect 5 ms 1376 KB Output isn't correct
30 Incorrect 4 ms 1628 KB Output isn't correct
31 Incorrect 3 ms 2652 KB Output isn't correct
32 Incorrect 3 ms 2652 KB Output isn't correct
33 Incorrect 3 ms 2652 KB Output isn't correct
34 Incorrect 2 ms 2536 KB Output isn't correct
35 Incorrect 5 ms 2652 KB Output isn't correct
36 Correct 4 ms 2656 KB Output is correct
37 Correct 2 ms 2520 KB Output is correct
38 Correct 74 ms 12692 KB Output is correct
39 Correct 1 ms 336 KB Output is correct
40 Incorrect 13 ms 3212 KB Output isn't correct
41 Correct 1 ms 336 KB Output is correct
42 Correct 20 ms 892 KB Output is correct
43 Correct 66 ms 12540 KB Output is correct
44 Incorrect 5 ms 1616 KB Output isn't correct
45 Incorrect 99 ms 12616 KB Output isn't correct
46 Correct 70 ms 12596 KB Output is correct
47 Incorrect 69 ms 12616 KB Output isn't correct
48 Incorrect 80 ms 12616 KB Output isn't correct
49 Correct 69 ms 12616 KB Output is correct
50 Incorrect 73 ms 12504 KB Output isn't correct
51 Incorrect 80 ms 12600 KB Output isn't correct
52 Incorrect 72 ms 12592 KB Output isn't correct
53 Incorrect 78 ms 12604 KB Output isn't correct
54 Incorrect 83 ms 12624 KB Output isn't correct
55 Incorrect 78 ms 12600 KB Output isn't correct
56 Correct 77 ms 12616 KB Output is correct
57 Incorrect 73 ms 12488 KB Output isn't correct
58 Incorrect 114 ms 12600 KB Output isn't correct
59 Incorrect 75 ms 12620 KB Output isn't correct
60 Correct 73 ms 12472 KB Output is correct
61 Correct 72 ms 12588 KB Output is correct
62 Correct 79 ms 12484 KB Output is correct
63 Correct 68 ms 12616 KB Output is correct
64 Correct 80 ms 12616 KB Output is correct
65 Incorrect 76 ms 12464 KB Output isn't correct
66 Incorrect 94 ms 12608 KB Output isn't correct
67 Incorrect 81 ms 12468 KB Output isn't correct
68 Incorrect 83 ms 12460 KB Output isn't correct
69 Incorrect 77 ms 12600 KB Output isn't correct
70 Incorrect 52 ms 9032 KB Output isn't correct
71 Incorrect 99 ms 12588 KB Output isn't correct
72 Incorrect 68 ms 12616 KB Output isn't correct
73 Incorrect 92 ms 12544 KB Output isn't correct
74 Incorrect 92 ms 12472 KB Output isn't correct
75 Incorrect 91 ms 12616 KB Output isn't correct
76 Incorrect 84 ms 12616 KB Output isn't correct
77 Incorrect 83 ms 12616 KB Output isn't correct
78 Incorrect 123 ms 12464 KB Output isn't correct
79 Incorrect 79 ms 12496 KB Output isn't correct
80 Incorrect 95 ms 12656 KB Output isn't correct
81 Incorrect 97 ms 12616 KB Output isn't correct
82 Incorrect 90 ms 12536 KB Output isn't correct
83 Incorrect 103 ms 12776 KB Output isn't correct
84 Incorrect 95 ms 12688 KB Output isn't correct
85 Incorrect 100 ms 12508 KB Output isn't correct
86 Incorrect 76 ms 12676 KB Output isn't correct
87 Incorrect 84 ms 12696 KB Output isn't correct
88 Incorrect 101 ms 12616 KB Output isn't correct
89 Incorrect 96 ms 12572 KB Output isn't correct
90 Incorrect 60 ms 9200 KB Output isn't correct
91 Incorrect 71 ms 12520 KB Output isn't correct
92 Incorrect 126 ms 12580 KB Output isn't correct
93 Incorrect 82 ms 12476 KB Output isn't correct
94 Incorrect 87 ms 12616 KB Output isn't correct
95 Incorrect 87 ms 12508 KB Output isn't correct
96 Incorrect 66 ms 12616 KB Output isn't correct
97 Incorrect 76 ms 12624 KB Output isn't correct
98 Incorrect 68 ms 12616 KB Output isn't correct
99 Incorrect 78 ms 12636 KB Output isn't correct
100 Incorrect 84 ms 12584 KB Output isn't correct